http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60475

--- Comment #3 from zosrothko at orange dot fr ---
(In reply to Jonathan Wakely from comment #1)
> (In reply to zosrothko from comment #0) 
> > $ gcc -xc++ -std=gnu++11  -o foo foo.c
> 
> To link a C++ program you should explicitly link to the C++ runtime library,
> using -lstdc++, or use g++ which does that automatically.
> 
> (If your source file is C++ why is your file called foo.c instead of having
> a C++ file extension?)

because the story starts with a C program. Here the point: there is a problem
with the declaration of snprintf with the std=c++11 in c++. Thus I started to
test first with gcc and the std(c90, c89), then I forget to switch to g++ for
testing the std(c++11,gnu++1). Thus as the gcc -xc++ -std=gnu++11 -c foo.c was
compiling without error, I just wanted to execute it. My mistake.... Sorry for
the noise...By the way, the error on snprintf not declared is invalid.

$ gcc -xc -std=c90 -c foo.c
$ gcc -xc -std=c89 -c foo.c
$
$ gcc -xc++ -std=c++11  -c foo.c
foo.c: In function 'int main()':
foo.c:5:27: error: 'snprintf' was not declared in this scope
  snprintf(buf, 10, "%i", 0);

$
$ gcc -xc++ -std=gnu++11  -c foo.c
$

Reply via email to