Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

error: expected identifier or ‘(’ before ‘__extension__’

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?

like image 327
Homunculus Reticulli Avatar asked Oct 25 '25 09:10

Homunculus Reticulli


1 Answers

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.

like image 140
Trevor Arjeski Avatar answered Oct 28 '25 01:10

Trevor Arjeski



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!