Boston Linux & Unix (BLU) Home | Calendar | Mail Lists | List Archives | Desktop SIG | Hardware Hacking SIG
Wiki | Flickr | PicasaWeb | Video | Maps & Directions | Installfests | Keysignings
Linux Cafe | Meeting Notes | Blog | Linux Links | Bling | About BLU

BLU Discuss list archive


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

[OT] Visual C++ question



Jerry Feldman <gaf at gaf.blu.org> writes:

> I teach C programming at Northeastern, and most of my students this
> quarter are using GCC, but WRT: Visual C++. 
> How does one tell Visual C++ that it should be compiling a straight C
> program, not C++. 
> 
> Also, the same might go for Borland also. 

In my experience, VC++ doesn't automatically go into "C only" mode
when compiling a file with a certain extension (like ".C").  I looked
for a flag to force this a long time ago but I don't remember if I
found anything or not.

However, assuming that VC++ is purporting to be a C compiler, what
happens when you send the following code through it?:


  /* author:  dan pop */
  #include <stdio.h>  

  #if defined __STDC_VERSION__ && __STDC_VERSION__ == 199901L
  int c99 = 1;
  #else
  int c99 = 0;
  #endif

  int main(void) 
  {
      if (1 //* */ 2
           ) {
          if (c99) puts("C99 compiler.");
          else if (sizeof 'a' > 1) puts("Broken C89 compiler.");
          else puts("C++ compiler.");
      }
      else puts("C89 compiler.");  
      return 0;
  }


You hit the nail on the head when you stated that C is not a subset of
C++ and C++ is not a superset of C... 

Regards,

--kevin
-- 
 If you want to program in C, program in C.  It's a nice language.  I
    use it occasionally...   :-)
            --Larry Wall in <7577 at jpl-devvax.JPL.NASA.GOV>





BLU is a member of BostonUserGroups
BLU is a member of BostonUserGroups
We also thank MIT for the use of their facilities.

Valid HTML 4.01! Valid CSS!



Boston Linux & Unix / webmaster@blu.org