gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-30 15:40:15 25 4
gpt4 key购买 nike

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

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com