首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在C中调用宏[ M68K Freescale的HIWARE编译器]

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

Stack Overflow用户
提问于 2014-01-13 23:26:20
回答 1查看 337关注 0票数 0

我正试着在c程序中调用一些宏。没有参数的宏是可以的,但是如果我添加了一个参数,我会得到错误。

例如,这就是我在c程序的头文件中调用的代码。

代码语言:javascript
复制
/**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);\
}

这是我得到的一个错误:

代码语言:javascript
复制
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

有什么建议吗?

谢谢你的帮助。

EN

回答 1

Stack Overflow用户

发布于 2014-01-13 23:35:33

在这一行上:

代码语言:javascript
复制
bglib_temp_msg.cmd_flash_ps_load.key=KEY;\

您似乎没有将bglib_temp_msg定义为结构。目前还不清楚这是否意味着在调用它的函数体中完成(即调用者是否应该具有该名称的局部变量),或者是否像我怀疑的那样,您想要类似于:

代码语言:javascript
复制
struct mystructuretype bglib_temp_msg;

第一个(显然是使用正确的结构名称)。记住使用#include或在使用之前使用相关的结构声明。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/21094982

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档