char vs char*

Todd Freed todd.freed@gmail.com
Tue Jun 15 17:19:00 GMT 2010


Dear GCC-help,

I don't know if this is a bug, but I suspect that it is.

Consider the following two declarations, which compile fine:

1 static char __attribute__((weakref("LNU__strmats__LNU"))) 
strmats(char* s, char* m, int* l, unsigned int options) 
__attribute__((nonnull));
2 static char* __attribute__((weakref("LNU__strmat__LNU"))) strmat(char* 
s, char* m, int* l, unsigned int options) __attribute__((nonnull));

Then, if I move the 'static' keyword, like so:

1 char static __attribute__((weakref("LNU__strmats__LNU"))) 
strmats(char* s, char* m, int* l, unsigned int options) 
__attribute__((nonnull));
2 char* static __attribute__((weakref("LNU__strmat__LNU"))) strmat(char* 
s, char* m, int* l, unsigned int options) __attribute__((nonnull));

The 1st declaration still compiles, but the 2nd one fails like this:

error.c:1: error: expected identifier or '(' before 'static'

I am compiling with (GCC for Cross-LFS 4.3.3.20090323)

If I use a typedef

typedef char* charstar

and return that instead, it works fine.

Thanks,

-Todd



More information about the Gcc-help mailing list