下面是一个c文件的内容。我正在生成一个查找表,当test.c以及尝试将其编译为测试程序时,出现以下错误:
In file included from test.c:1:
lut.h:1: error: expected â=â, â,â, â;â, âasmâ or â__attribute__â before âvaluesâ
有人对这个错误有任何见解吗?我正在尝试将此查找表作为 .c 文件包含在内以供使用。(我不会选择这样做,但这是一个要求)。
static const int16_t values[] =
{
29, 30, 31
};
我正在使用的测试程序(仅用于测试编译)是:
#include <stdio.h>
#include "lut.h"
int main ()
{
printf("successn");
return 0;
}
我编译:
gcc test.c
我无法重现此问题。我在lut.h
有:
#include <stdint.h>
static const int16_t values[] = {
29, 30, 31
};
在test.c
:
#include <stdio.h>
#include "lut.h"
int main() {
printf("%dn", values[1]);
return 0;
}
我得到:
$ gcc test.c
$ ./a.out
30
你能提供更多信息吗?也许复制粘贴正是您的lut.h
的样子?
您尚未定义int16_t
。 尝试包括stdint.h