作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试在我的 C 程序中调用一些宏。没有参数的宏是可以的,但是如果我添加参数,我会收到错误。
例如,这是我从 C 程序中的头文件中调用的内容。
/**Retrieve the value from the persistent store for the given key **/
#define wifi_cmd_flash_ps_load(KEY) \
{\
bglib_temp_msg.cmd_flash_ps_load.key=KEY;\
bglib_temp_msg.header=(((uint32)wifi_dev_type_wifi|(((uint32)2+0)>>8)))|((((uint32)2+0)&0xff)<<8)|((uint32)0x7<<16)|((uint32)0x4<<24);\
bglib_output (4+2,(uint8*)&bglib_temp_msg,0,(uint8*)NULL);\
}
/**Uploading is finished.**/
#define wifi_cmd_dfu_flash_upload_finish() \
{\
bglib_temp_msg.header=(((uint32)wifi_dev_type_wifi|(((uint32)0+0)>>8)))|((((uint32)0+0)&0xff)<<8)|((uint32)0x0<<16)|((uint32)0x3<<24);\
bglib_output (4+0,(uint8*)&bglib_temp_msg,0,(uint8*)NULL);\
}
这是我收到的错误:
D:\_Prj_1000\Prj_1000.c(496): ERROR C1085: cmd_flash_ps_load is not a member
D:\_Prj_1000\Prj_1000.c(496): ERROR C1816: Unknown struct- or union-member
D:\_Prj_1000\Prj_1000.c(496): ERROR C1421: Undefined class/struct/union
D:\_Prj_1000\Prj_1000.c(496): ERROR C1815: k not declared (or typename)
D:\_Prj_1000\Prj_1000.c(496): ERROR C1815: bglib_temp_msg not declared (or typename)
D:\_Prj_1000\Prj_1000.c(496): ERROR C1421: Undefined class/struct/union
D:\_Prj_1000\Prj_1000.c(496): ERROR C1815: uint32 not declared (or typename)
D:\_Prj_1000\Prj_1000.c(496): ERROR C2801: ')' missing
D:\_Prj_1000\Prj_1000.c(496): ERROR C1815: uint32 not declared (or typename)
D:\_Prj_1000\Prj_1000.c(496): ERROR C2801: ')' missing
D:\_Prj_1000\Prj_1000.c(496): ERROR C2801: ';' missing
D:\_Prj_1000\Prj_1000.c(496): ERROR C1815: uint32 not declared (or typename)
D:\_Prj_1000\Prj_1000.c(496): ERROR C2801: ')' missing
D:\_Prj_1000\Prj_1000.c(496): ERROR C1815: uint32 not declared (or typename)
D:\_Prj_1000\Prj_1000.c(496): ERROR C2801: ')' missing
D:\_Prj_1000\Prj_1000.c(496): ERROR C1815: uint32 not declared (or typename)
D:\_Prj_1000\Prj_1000.c(496): ERROR C2801: ')' missing
D:\_Prj_1000\Prj_1000.c(496): ERROR C1815: bglib_output not declared (or typename)
D:\_Prj_1000\Prj_1000.c(496): ERROR C1815: uint8 not declared (or typename)
D:\_Prj_1000\Prj_1000.c(496): ERROR C2450: Expected: . * + - & ! ~ ++ -- -> [ ( IDENT CONSTANT STRING sizeof __alignof__ __va_sizeof__
D:\_Prj_1000\Prj_1000.c(496): ERROR C1827: Arithmetic types expected
D:\_Prj_1000\Prj_1000.c(496): ERROR C1815: bglib_temp_msg not declared (or typename)
D:\_Prj_1000\Prj_1000.c(496): ERROR C1826: Integer-expression expected
D:\_Prj_1000\Prj_1000.c(496): ERROR C1815: uint8 not declared (or typename)
D:\_Prj_1000\Prj_1000.c(496): ERROR C2450: Expected: . * + - & ! ~ ++ -- -> [ ( IDENT CONSTANT STRING sizeof __alignof__ __va_sizeof__
D:\_Prj_1000\Prj_1000.c(496): ERROR C1827: Arithmetic types expected
D:\_Prj_1000\Prj_1000.c(496): ERROR C1844: Call-operator applied to non-function
D:\_Prj_1000\Prj_1000.c(496): ERROR C2801: ')' missing
D:\_Prj_1000\Prj_1000.c(496): WARNING C1420: Result of function-call is ignored
D:\_Prj_1000\Prj_1000.c(507): ERROR C1815: TPU_init not declared (or typename)
D:\_Prj_1000\Prj_1000.c(508): ERROR C1815: TPU_Buzzer not declared (or typename)
D:\_Prj_1000\Prj_1000.c(520): ERROR C1815: tm_init not declared (or typename)
D:\_Prj_1000\Prj_1000.c(526): ERROR C1815: BulkStart not declared (or typename)
D:\_Prj_1000\Prj_1000.c(528): ERROR C1815: tm_start not declared (or typename)
D:\_Prj_1000\Prj_1000.c(528): ERROR C1815: tm_create not declared (or typename)
D:\_Prj_1000\Prj_1000.c(528): ERROR C1815: T_Background not declared (or typename)
D:\_Prj_1000\Prj_1000.c(528): ERROR C1844: Call-operator applied to non-function
D:\_Prj_1000\Prj_1000.c(528): ERROR C1844: Call-operator applied to non-function
D:\_Prj_1000\Prj_1000.c(530): ERROR C1815: tm_startup not declared (or typename)
D:\_Prj_1000\Prj_1000.c(543): ERROR C1815: bglib_output not declared (or typename)
D:\_Prj_1000\Prj_1000.c(543): ERROR C1815: on_message_send not declared (or typename)
D:\_Prj_1000\Prj_1000.c(548): ERROR C1815: bglib_temp_msg not declared (or typename)
D:\_Prj_1000\Prj_1000.c(548): ERROR C1421: Undefined class/struct/union
D:\_Prj_1000\Prj_1000.c(548): ERROR C1815: uint32 not declared (or typename)
D:\_Prj_1000\Prj_1000.c(548): ERROR C2801: ')' missing
D:\_Prj_1000\Prj_1000.c(548): ERROR C1815: uint32 not declared (or typename)
D:\_Prj_1000\Prj_1000.c(548): ERROR C2801: ')' missing
D:\_Prj_1000\Prj_1000.c(548): ERROR C2801: ';' missing
D:\_Prj_1000\Prj_1000.c(548): ERROR C1815: uint32 not declared (or typename)
D:\_Prj_1000\Prj_1000.c(548): ERROR C2801: ')' missing
D:\_Prj_1000\Prj_1000.c(548): ERROR C1815: uint32 not declared (or typename)
D:\_Prj_1000\Prj_1000.c(548): WARNING C1420: Result of function-call is ignored
D:\_Prj_1000\Prj_1000.c(549): WARNING C1420: Result of function-call is ignored
有什么建议吗?
感谢您的帮助。
最佳答案
在这一行:
bglib_temp_msg.cmd_flash_ps_load.key=KEY;\
您似乎没有将bglib_temp_msg
定义为结构。目前尚不清楚这是否意味着在调用它的函数体内完成(即调用者是否应该拥有该名称的局部变量),或者正如我怀疑的那样,您是否想要类似的东西:
struct mystructuretype bglib_temp_msg;
首先(显然具有正确的结构名称)。请记住#include
或在使用之前添加相关结构声明。
关于在 C 中调用宏 [用于 M68K Freescale 的 HIWARE 编译器],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21094982/
关闭。此题需要details or clarity 。目前不接受答案。 想要改进这个问题吗?通过 editing this post 添加详细信息并澄清问题. 已关闭 9 年前。 Improve th
我是一名优秀的程序员,十分优秀!