【XR806开发板试用】C++应用
编辑
/home/make/xr806_openharmony/device/xradio/xr806/liteos_m/config.gni
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);