gcc c++ option

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi folks,

 I have a question about where this is a bug or not?

 It seems that gcc all ways turns __cplusplus true even when you only include
.c and .h input files?  Does this seem wrong to you all?

 If you can see a problem, please let me know.  Here is a set of test file:

/* global.h ---------------------------------------------------------------- */

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

#ifdef __cplusplus
extern "C" {
#endif
char stuff[50];
int    RC;
int    sub1();
int    sub2();
#ifdef __cplusplus
}
#endif

/* global.c ------------------------------------------------------------------ */

#include "global.h"

int main( int argc, char **argv )  {

 printf("\n");
if( argc > 1 ) {
   strcpy(stuff, argv[1]); }

 printf("%10s %3d Stuff = '%s'\n", __FILE__, __LINE__, stuff);
RC = sub1();
 printf("%10s %3d Stuff = '%s' RC = %d\n", __FILE__, __LINE__, stuff, RC );
RC = sub2();
 printf("%10s %3d Stuff = '%s' RC = %d\n\n", __FILE__, __LINE__, stuff, RC );

 return 0; }

/* subs.c ------------------------------------------------------------- */

#include "global.h"

int
sub2() {
 strcat( stuff, ", Sub2 hello" );
 printf("%10s %3d Stuff = '%s'\n", __FILE__, __LINE__, stuff);
 return 99; }

int
sub1() {
 strcat(stuff,", Sub1 Here");
 printf("%10s %3d Stuff = '%s'\n", __FILE__, __LINE__, stuff);
 return 1; }





--
William Estrada

Email      : MrUmunhum at popdial dot com
Resume     : www.Mt-Umunhum-Wireless.net/resume/william_estrada.html
HTTP       : www.Mt-Umunhum-Wireless.net

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux