[OT] Visual C++ question
Kevin D. Clark
kclark at CetaceanNetworks.com
Fri Feb 14 15:56:15 EST 2003
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>
More information about the Discuss
mailing list