卐词意不达 · 2021年12月24日

【XR806开发板试用】C++ hello world

【XR806开发板试用】C++应用

编辑
/home/make/xr806_openharmony/device/xradio/xr806/liteos_m/config.gni

添加
出处 XR806 C++支持

board_cxx_flags = []
board_cxx_flags += SDK_cflags
board_cxx_flags += [
    "-includelog/log.h",
    "-DVIRTUAL_HCI",
    "-DCONFIG_ARM",
    #"-DNULL=((void*)0)",
    #"-std=c++17",
      "-lstdc++",
      "-fno-rtti",
      "-fno-exceptions",
]

cd /home/make/xr806_openharmony/device/xradio/xr806/ohosdemo/
编辑
BUILD.gn


group("ohosdemo") {
    deps = [
        #"cplusplus:app_cplusplus",
    ]
}

mkdir cplusplus
cd cplusplus
编辑 BUILD.gn

static_library("app_cplusplus") {
   configs = []

   sources = [
  "cpp_mem.cpp",
   ]

   cflags = board_cflags
   #c++
   cflags_cc = board_cxx_flags

   include_dirs = board_include_dirs
   include_dirs += [
    "include/",
    ".",
    "//kernel/liteos_m/kernel/arch/include",
   ]

   deps = [
    #".",  
   ]
}

编辑
cpp_mem.cpp

#include <stdio.h>

/*typedef unsigned long                UINT32;*/
#ifdef __cplusplus
extern "C"
{
#endif
#include "ohos_init.h"
#include "kernel/os/os.h"
#ifdef __cplusplus
}
#endif
extern "C"
{
    typedef unsigned int UINT32;
    void LOS_Msleep(UINT32 mSecs);
}

static OS_Thread_t g_main_thread;

static void MainThread(void *arg)
{
    while (1)
    {
        printf("hello world!\n");
        LOS_Msleep(1000);
    }
}

void HelloTestMain(void)
{
    printf("Wifi Test Start\n");

    if (OS_ThreadCreate(&g_main_thread, "MainThread", MainThread, NULL,
                        OS_THREAD_PRIO_APP, 4 * 1024) != OS_OK)
    {
        printf("[ERR] Create MainThread Failed\n");
    }
}

SYS_RUN(HelloTestMain);
推荐阅读
关注数
13823
内容数
139
全志XR806开发板相关的知识介绍以及应用专栏。
目录
极术微信服务号
关注极术微信号
实时接收点赞提醒和评论通知
安谋科技学堂公众号
关注安谋科技学堂
实时获取安谋科技及 Arm 教学资源
安谋科技招聘公众号
关注安谋科技招聘
实时获取安谋科技中国职位信息