Visual C++ support of C99 by using "C++ mode" (/TP)



To what extent does
Microsoft Visual C++
also called: VC++
also called: Microsoft (R) 32-bit C/C++ Optimizing Compiler

support C99?



VC++ compiles either in C mode (which is def. *not* C99!):
cl.exe /TC c_file.c

or in C++ mode
cl.exe /TP cpp_file.cpp

In C mode (/TC), VC++ is definately *not* conform to C99!




But an interesing question is:
How conform is VC++ to C99, when used in C++ mode (/TP)??

This is particularly interesting, when considering that
the C99 library is part of C++ TR1.
http://groups.google.at/group/comp.lang.c/browse_thread/thread/a6d0e5ddb976ecb1/95879cd6fca0acc8?hl=en#95879cd6fca0acc8

To what extent does the latest VC++ (in C++ mode /TP) support C++ TR1?
To what extent does the latest VC++ (in C++ mode /TP) use Dinkumware
libraries?




The following is valid C99 code:

/************* c_test.c ***************/
#include <stdio.h>
#include <stdbool.h>
#include <limits.h>

int main( void )
{
bool b = true;
if (b)
printf("hello world\n");

char c = 5;
printf("%hhd\n", c);

int size = INT_MAX / 10000;
printf("%d\n", size);
char a[size];
a[0] = 'a';
a[1] = 'b';
a[2] = '\0';
printf("%s\n", (char *)&a);

return 0;
}


The above C99 code can be compiled on VC++, by just commenting the 2nd
line (see below!)



/************* cpp_test.cpp ***************/
#include <stdio.h>
//#include <stdbool.h>
#include <limits.h>

int main( void )
{
bool b = true;
if (b)
printf("hello world\n");

char c = 5;
printf("%hhd\n", c);

const int size = INT_MAX / 10000;
printf("%d\n", size);
char a[size];
a[0] = 'a';
a[1] = 'b';
a[2] = '\0';
printf("%s\n", (char *)&a);

return 0;
}

To compile with VC++:
cl.exe \TP cpp_test.cpp

Works perfectly! Hmmm... almost C99...???




Comments appreciated,
Albert




Note:
Microsoft VC++ compiler can be obtained for free:
"Visual C++": Microsoft (R) 32-bit C/C++ Optimizing Compiler"

Search
http://www.microsoft.com/downloads
for
"Microsoft Windows SDK for Windows Vista"
On download page; check the "System Requirements":
e.g.
Windows XP Professional SP2 (OK!), Windows Vista, etc.
(Otherwise search for another compatible "Microsoft Windows SDK")

After installing:
The batch-skript for environment variables can be envoked as follows
"C:\Program Files\Microsoft SDKs\Windows\v6.0\bin\setenv.cmd" /
Release /x86 /xp
In setenv.cmd:
'color 07' is normal white on black

Compiler is here:
C:\Programme\Microsoft SDKs\Windows\v6.0\VC\Bin\cl.exe

.



Relevant Pages

  • Re: a problem porting an application from linux to windows, oh the agony -- please help?
    ... > I'm working on porting a monstrosity written in Python, C, an Fortran ... This really looks like a question for a Windows programming group ... MinGW C compiler, but you don't say whose C runtime you're linking ... Microsoft C compiler products ...
    (comp.programming)
  • Re: Is 3.15p -still- the latest GNAT p release?
    ... data in an opaque data format such as Microsoft Word or Excel, ... Microsoft don't mind that they, too, have to rewrite their ... date" and "integrated with the latest Windows". ... > keep demand up for new releases of a compiler. ...
    (comp.lang.ada)
  • Re: Where to Start?
    ... > I want to buy a new compiler but dont know which. ... Currently im running Windows ... Microsoft is closer to be standard than Borland, but I might be very wrong. ...
    (alt.comp.lang.learn.c-cpp)
  • Re: [SLE] Gnome disappointment
    ... > A compiler. ... ;) Though he did this before Microsoft was even well know. ... > Gates got away with not selling DOS outright to IBM, so he had MS-DOS, they ... > Gates then started realising Windows wasn't in competition with Unix. ...
    (SuSE)
  • Cross Compiler (DOS) läuft nicht unter Windows XP
    ... Der Tasking Compiler c166 nutzt DOS4GW und läuft nicht unter Windows XP auf ... Copyright 1985-2001 Microsoft Corp. ... Tasking sagt, das sei ein lokales Problem des Rechners.- ...
    (microsoft.public.de.german.windowsxp.sonstiges)