Ashay wrote:
Hi,
I am getting compilation error "error: parse error before
"__extension__"" for following line of 'C' code:
extern char *strchr(const char *s, int c);
("I had to put this line for some other reasons")
I am using gcc 3.4.2. And, this error is coming only with '-O' option.
With '-g', it is compiling.
Can somebody please help me out.
You have probably #include'd <string.h> in the source,
either directly or indirectly. Once you have done so, you
must not attempt to re-declare the names that <string.h> has
already declared for you. Three possible fixes:
- (poor) Write `extern char *(strchr)( ...etc... );'
- (better) Delete the offending declaration altogether.
- (best) Delete the declaration *and* insert an explicit
#include <string.h> if it's not already there (some
other #include file may pull in <string.h> on your
behalf, but that might change someday -- and if you
#include it explicitly, you'll guard against the
breakage that "someday" might otherwise cause).
--
Er*********@sun.com