导航

    全志在线开发者论坛

    • 注册
    • 登录
    • 搜索
    • 版块
    • 话题
    • 在线文档
    • 社区主页

    直接拷贝官网点灯代码出错error: unknown type name '\U0000200b' 及解决方案

    Wireless & Analog Series
    2
    3
    1815
    正在加载更多帖子
    • 从旧到新
    • 从新到旧
    • 最多赞同
    回复
    • 在新帖中回复
    登录后回复
    此主题已被删除。只有拥有主题管理权限的用户可以查看。
    • O
      oiouou123 LV 5 最后由 编辑

      拷贝点灯 hb build -f 遇到了如下报错

      ../../../device/xradio/xr806/ohosdemo/LED/main.c:17:1: error: unknown type name '\U0000200b'
         17 | ​    IoTGpioSetOutputVal(GPIO_ID_PA21, 1);                                      //(5)输出高电平
            |  
      ../../../device/xradio/xr806/ohosdemo/LED/main.c:8:22: error: expected declaration specifiers or '...' before numeric constant
          8 | #define GPIO_ID_PA21 21
            |                      ^~
      ../../../device/xradio/xr806/ohosdemo/LED/main.c:17:28: note: in expansion of macro 'GPIO_ID_PA21'
         17 | ​    IoTGpioSetOutputVal(GPIO_ID_PA21, 1);                                      //(5)输出高电平
            |                         ^~~~~~~~~~~~
      ../../../device/xradio/xr806/ohosdemo/LED/main.c:17:42: error: expected declaration specifiers or '...' before numeric constant
         17 | ​    IoTGpioSetOutputVal(GPIO_ID_PA21, 1);                                      //(5)输出高电平
            |                                       ^
      ../../../device/xradio/xr806/ohosdemo/LED/main.c:18:1: error: unknown type name '\U0000200b'
         18 | ​    OS_MSleep(500);
            |  
      ../../../device/xradio/xr806/ohosdemo/LED/main.c:18:18: error: expected declaration specifiers or '...' before numeric constant
         18 | ​    OS_MSleep(500);
            |               ^~~
      ../../../device/xradio/xr806/ohosdemo/LED/main.c:19:1: error: unknown type name '\U0000200b'
         19 | ​    IoTGpioSetOutputVal(GPIO_ID_PA21, 0);                                      //(6)输出高电平
            |  
      ../../../device/xradio/xr806/ohosdemo/LED/main.c:8:22: error: expected declaration specifiers or '...' before numeric constant
          8 | #define GPIO_ID_PA21 21
            |                      ^~
      ../../../device/xradio/xr806/ohosdemo/LED/main.c:19:28: note: in expansion of macro 'GPIO_ID_PA21'
         19 | ​    IoTGpioSetOutputVal(GPIO_ID_PA21, 0);                                      //(6)输出高电平
            |                         ^~~~~~~~~~~~
      ../../../device/xradio/xr806/ohosdemo/LED/main.c:19:42: error: expected declaration specifiers or '...' before numeric constant
         19 | ​    IoTGpioSetOutputVal(GPIO_ID_PA21, 0);                                      //(6)输出高电平
            |                                       ^
      ../../../device/xradio/xr806/ohosdemo/LED/main.c:20:1: error: unknown type name '\U0000200b'
         20 | ​    OS_MSleep(500);
            |  
      ../../../device/xradio/xr806/ohosdemo/LED/main.c:20:18: error: expected declaration specifiers or '...' before numeric constant
         20 | ​    OS_MSleep(500);
            |               ^~~
      ../../../device/xradio/xr806/ohosdemo/LED/main.c: In function 'LEDMain':
      ../../../device/xradio/xr806/ohosdemo/LED/main.c:28:1: error: '\U0000200b' undeclared (first use in this function)
         28 | ​        OS_THREAD_PRIO_APP, 4 * 1024) != OS_OK) {
            |  
      ../../../device/xradio/xr806/ohosdemo/LED/main.c:28:1: note: each undeclared identifier is reported only once for each function it appears in
      ../../../device/xradio/xr806/ohosdemo/LED/main.c:28:4: error: expected ')' before 'OS_PRIORITY_NORMAL'
         28 | ​        OS_THREAD_PRIO_APP, 4 * 1024) != OS_OK) {
            | ^
            | )
      ../../../device/xradio/xr806/ohosdemo/LED/main.c:27:7: error: too few arguments to function 'OS_ThreadCreate'
         27 |   if (OS_ThreadCreate(&g_main_thread, "MainThread", MainThread, NULL,
            |       ^~~~~~~~~~~~~~~
      In file included from ../../../device/xradio/xr806/xr_skylark/include/kernel/os/os.h:34,
                       from ../../../device/xradio/xr806/ohosdemo/LED/main.c:3:
      ../../../device/xradio/xr806/xr_skylark/include/kernel/os/os_thread.h:92:11: note: declared here
         92 | OS_Status OS_ThreadCreate(OS_Thread_t *thread, const char *name,
            |           ^~~~~~~~~~~~~~~
      ../../../device/xradio/xr806/ohosdemo/LED/main.c:29:4: error: expected ';' before 'printf'
         29 | ​    printf("[ERR] Create MainThread Failed\n");
            | ^   ~~~~~~
            | ;
      [101/252] gcc cross compiler obj/kernel/liteos_m/kal/posix/src/libposix.time.o
      

      尝试了下把17行前边的字符全删了,重新编译不报错了
      如法炮制把其他出错行搞了下,成功编译
      感觉是官网代码拷贝的时候混入了奇怪的字符,特发帖提醒下各位(吐槽下)

      1 条回复 最后回复 回复 引用 分享 1
      • P
        PWB555 LV 2 最后由 编辑

        前几天我也遇到了同样的问题,但我是通过VS code的“将缩进转换为空格”功能解决的。

        O 1 条回复 最后回复 回复 引用 分享 0
        • O
          oiouou123 LV 5 @PWB555 最后由 编辑

          @pwb555 我试试,谢谢!

          1 条回复 最后回复 回复 引用 分享 0
          • 1 / 1
          • First post
            Last post

          Copyright © 2024 深圳全志在线有限公司 粤ICP备2021084185号 粤公网安备44030502007680号

          行为准则 | 用户协议 | 隐私权政策