Tom Williams <tomdkat@xxxxxxxxxxx> writes:Thanks! :)
Apparently, the Linux 2.6 kernel headers were changed to use
__attribute_const__ syntax instead of __attribute__((const)):
__attrbute_const__ is not valid gcc syntax.
However, it is a preprocessor macro defined by the Linux sources which expands into valid gcc syntax. I think the file is include/linux/compiler.h, or some such.
Ian
I found the following in /usr/include/linux/compiler.h:
#ifndef __attribute_const__ # define __attribute_const__ /* unimplemented */ #endif
Which I looks like it's trying to define __attribute_const__ to nothing so it will be automatically removed from this:
static __inline__ __attribute_const__ int foo()
resulting in:
static __inline__ int foo()
So, I wrote a test prog to see if this is actually the case:
tom@linux:~$ cat tom.c #include <linux/compiler.h>
#ifdef __attribute_const__ #error It is defined! #endif
static __inline__ __attribute_const__ int foo() { return 0; }
int main(int argc, char **argv) { foo();
return 0; } tom@linux:~$
and this is what happens when I compile it:
tom@linux:~$ make tom cc tom.c -o tom tom.c:7: error: syntax error before "int" make: *** [tom] Error 1 tom@c71414-a:~$ gcc -E tom.c # 1 "tom.c" # 1 "<built-in>" # 1 "<command line>" # 1 "tom.c" # 1 "/usr/include/linux/compiler.h" 1 3 4 # 2 "tom.c" 2
static __inline__ __attribute_const__ int foo() { return 0; }
int main(int argc, char **argv) { foo();
return 0; } tom@linux:~$ cc --version cc (GCC) 3.3.3 Copyright (C) 2003 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
tom@linux:~$
Any idea on what might be up? I guess the pre-processor isn't replacing the __attribute_const__ like it should???
Thanks...
Peace...
Tom