错误:预期的标识符或“__extension__”之前的“(”
当我尝试编译代码库中的某个文件时,出现奇怪的编译时错误消息。
使此错误更奇怪的是,它仅在我在发布模式下构建时发生 - 它在调试模式下编译没有问题。
以下是有问题的文件的(全部)内容:
#include <string.h>
char * strtok_r(char *s, const char *delim, char **save_ptr)
{
char *token;
if (s == NULL)
s = *save_ptr;
s += strspn (s, delim);
if (*s == '\0')
return NULL;
token = s;
s = strpbrk (token, delim);
if (s == NULL)
*save_ptr = strchr (token, '\0');
else
{
*s = '\0';
*save_ptr = s + 1;
}
return token;
}
我正在 Ubuntu 10.0.4 上使用 gcc (Ubuntu 4.4.3-4ubuntu5) 4.4.3 进行编译
有谁知道为什么我会收到此错误?
I am having a strange compile time error message when attempting to compile one of the files in my codebase.
What makes this error more wierd is that it only occurs when I'm building in release mode - it compiles with no problem in Debug mode.
Below is the (entire) content of the offending file:
#include <string.h>
char * strtok_r(char *s, const char *delim, char **save_ptr)
{
char *token;
if (s == NULL)
s = *save_ptr;
s += strspn (s, delim);
if (*s == '\0')
return NULL;
token = s;
s = strpbrk (token, delim);
if (s == NULL)
*save_ptr = strchr (token, '\0');
else
{
*s = '\0';
*save_ptr = s + 1;
}
return token;
}
I am compiling with gcc (Ubuntu 4.4.3-4ubuntu5) 4.4.3 on Ubuntu 10.0.4
Does anyone know why I am getting this error?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您不能使用名称
strtok_r
作为函数名称,因为它已经在 string.h 库中。如果您使用strtok_rrr
或其他东西,则可以正常编译。You cant use the name
strtok_r
for your function name since it is already in the string.h library. Compiles fine if you usestrtok_rrr
or something.