在C中调用宏[M68K Freescale的HIWARE编译器]

时间:2014-01-13 15:26:20

标签: c compiler-construction macros compiler-errors

我正在尝试在我的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

有什么建议吗?

感谢您的帮助。

1 个答案:

答案 0 :(得分:1)

在这一行:

bglib_temp_msg.cmd_flash_ps_load.key=KEY;\

您似乎没有将bglib_temp_msg定义为struct。目前尚不清楚这是否意味着要在调用它的函数体中完成(即调用者是否具有该名称的局部变量),或者是否,正如我怀疑的那样,你想要这样的东西:

struct mystructuretype bglib_temp_msg;

首先(显然具有正确的结构名称)。请记住#include或在相关结构声明的使用之前。