错误:预期的标识符或“__extension__”之前的“(”

发布于 2024-12-14 00:13:13 字数 615 浏览 1 评论 0原文

当我尝试编译代码库中的某个文件时,出现奇怪的编译时错误消息。

使此错误更奇怪的是,它仅在我在发布模式下构建时发生 - 它在调试模式下编译没有问题。

以下是有问题的文件的(全部)内容:

#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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

倾听心声的旋律 2024-12-21 00:13:13

您不能使用名称 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 use strtok_rrr or something.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文