数组初始化错误#define
我正在 C 中使用#define 初始化数组,但我不断收到错误“预期表达式”
以下是代码片段
#include "File2.h"
File 1.h
Int32 dataBuff[SCRATCH_BUFF_SZ];
File2.h
#define SCRATCH_BUFF_SZ ( SAMP_BUFF_LEN \
+ CORR_BUFF_LEN \
+ KERNEL_BUFF_LEN \
+ CE_BUFF_LEN \
)
我不明白这里出了什么问题。错误是在宏定义的每个参数行上将 #define
指令指向为“预期表达式”
I am initializing an array using #define
s in C, but I keep getting error "Expected an Expression"
Following is code snippet
#include "File2.h"
File 1.h
Int32 dataBuff[SCRATCH_BUFF_SZ];
File2.h
#define SCRATCH_BUFF_SZ ( SAMP_BUFF_LEN \
+ CORR_BUFF_LEN \
+ KERNEL_BUFF_LEN \
+ CE_BUFF_LEN \
)
I dont understand what is wrong here. Error is pointing to #define
directive as "Expected an Expression" on each parameter line of Macro def
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
两个建议:
Two suggestions:
我的猜测是你在 SCRACTCH_BUFF_SZ 中的 #define 常量之一没有像你想象的那样定义?
即
SAMP_BUFF_LEN
CORR_BUFF_LEN
KERNEL_BUFF_LEN
CE_BUFF_LEN
也许不是你想的那样?
my guess is one of your #defined constants in SCRACTCH_BUFF_SZ is not defined as you think?
ie
SAMP_BUFF_LEN
CORR_BUFF_LEN
KERNEL_BUFF_LEN
CE_BUFF_LEN
are not what you think perhaps?
需要表达式: + 或 = 等运算符的右操作数需要表达式,但没有出现可识别的表达式。
确保 SCRATCH_BUFF_SZ 中的宏之间没有新行
(宏未损坏)
Expected an Expression: An operator such as + or = requires an expression for its right operand, but no recognizable expression appears.
Make sure there is no new line between your macros
(macro is not broken)
in SCRATCH_BUFF_SZ我仔细检查了所有事情,并保留了您的评论。
这是编译器配置错误。
我正在使用 Code Composer Studio。我检查了其中的预处理器选项,现在它工作正常。
我应该尝试使用其他编译器来隔离问题。
感谢您的宝贵时间!
谢谢
I double checked every thing keeping your comments in view.
It was a compiler configuration error.
I am using Code Composer Studio. I checked preprocessor option in it and now it works fine.
I should have tried on other compiler to isolate the problem.
appreciate your time!
Thanks