2 msgdifferent versions of gcc for kernel and usersp...
8 msgGCC ARM Cross Linker Problem
2 msgGCC enquires
1 msgRead and get back(It Urgent)
3 msgHow to list all public symbols in a file/project?
1 msgmudflap warning: unaccessed registered object:
2 msggcc -fstack-protector-all option
3 msgLinker Problem Help Required
3 msgglobal objects order-of-construction & orde...

implicit declaration warning only when using st...
\ Glen Beane (17 Aug 2006)
. \ Ian Lance Taylor (17 Aug 2006)

2 msgUsing a lower version of gcc
3 msgis compiler error?
2 msgmath functions
1 msgCompiling Simplescalar
1 msgSegmentation fault problem with C & Inline ...
2 msgHelp gcc compilation on Solaris 8
6 msgUnderstand cross compiling
1 msgcompilation time increased from 10 sec to 24 sec
1 msggcc 4.1.1 problem creating C++ shared library
2 msgexpected declaration specifiers or ... before (...
Subject:implicit declaration warning only when using std=c99
Group:Gcc-help
From:Glen Beane
Date:17 Aug 2006


I have been developing a C program using gcc 4 on Apple OS X. Today I copied my source over to a quad core AMD Opteron box running SuSE linux with gcc v 3.3.3 and compiled.

I have been compiling this program with -std=c99 so that I can declare variables inside of a for loop statement
e.g. for (int i = 0; i <foo; i++)


on the suse box, I would get implicit declaration warnings for strdup, strtok_r, and lstat. I verified that I was including the proper .h files, and no such warnings were produced on the OS X box.

I made the following test program and determined that I only got the warning if I used -std=c99. -std=gnu99 did not produce warnings, nor did the default std. I then tried compiling the test program with -std=c99 -D_GNU_SOURCE and it did not produce the warnings. What is it about -std=c99 on this system that requires _GNU_SOURCE to be defined in order for the prototypes for strdup, strtok_r, and lstat to be properly included? Should I just compile my program with -std=gnu99 and forget about it?


test program:

#include <string.h>
#include <stdio.h>


int main(int argc, char *argv[])
{
char *str = strdup(argv[0]);

printf("%s\n", str);

return 0;

}



--
Glen L. Beane
Software Engineer II
The Jackson Laboratory
Phone (207) 288-6153


© 2004-2008 readlist.com