c - 错误: expected identifier or '(' with C array declaration

标签 c gcc syntax-error

在我的头文件中,我有一个声明 MEMORY_SIZE 变量的语句。然后我想使用 MEMORY_SIZE 作为数组的大小来创建两个数组。这是我的头文件代码:

#ifndef MEMORY_SIZE
#define MEMORY_SIZE 1024*512
#endif

在我的主文件中,我用于缓冲区的代码是:

//buffers
unsigned char [MEMORY_SIZE] memBytes;
unsigned char [MEMORY_SIZE] secBytes;

之后,当我使用 gcc 进行编译时,我收到消息“error:两个数组的预期标识符或 '(' ”。稍后在代码中,当我尝试使用该数组时,我收到“error: use of undeclared标识符'memBytes'“

有人看到这个问题吗?

最佳答案

问题是您正在使用 C 编译器编译 Java。

unsigned char memBytes[MEMORY_SIZE];

认真地拿一本 C 书。(看来你做到了。在这种情况下,放弃 Java 书。)

关于c - 错误: expected identifier or '(' with C array declaration,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15936564/

相关文章:

sql - SQL查询可在PL/SQL中使用,但不能在Visual Studio中使用

wordpress - Nivo slider 未加载

sql - ORA-00907 : missing right parenthesis (While Creating the Table)

C#:如何将嵌套结构从 C 转换为 C#?

c - 两个字符串中的第一个字符不会在 C 中交换

获取 sin() 值时的 C 构建错误

c++ - 重新分配而不释放旧内存

c - _Static_assert 替换以在 C 中显示值

c - C 中的递归函数(打印金字塔#)

c - 链表插入简单