By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,054 Members | 902 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,054 IT Pros & Developers. It's quick & easy.

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

P: n/a
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.l...879cd6fca0acc8

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

Mar 31 '07 #1
Share this Question
Share on Google+
10 Replies


P: n/a
al********@gmail.com wrote:
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!)
In other words, by making it valid C++ and invalid C99.

What's your point?

Mar 31 '07 #2

P: n/a
al********@gmail.com said:
To what extent does
Microsoft Visual C++
also called: VC++
also called: Microsoft (R) 32-bit C/C++ Optimizing Compiler

support C99?
Because Visual C supports C90, it has de facto support for most of C99
(because most of C99 is basically C90), but it makes no claims of C99
conformance. Neither has Microsoft expressed the slightest interest in
supporting C99 until a significant proportion of their customers
requires it (which doesn't seem to be about to happen any time soon).

<snip>

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
Mar 31 '07 #3

P: n/a
On Mar 31, 1:20 pm, "Harald van Dijk" <true...@gmail.comwrote:
albert....@gmail.com wrote:
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!)

In other words, by making it valid C++ and invalid C99.

What's your point?
My point is:
Maby the difference between VC++ in C++ mode and C99 is marginal.
(In the example above, only the header is not known in the current VC+
+ (but bool is supported anyway))

And maby this difference will get even smaller, if VC++ adopts (or
conforms more closely to) newer C++ standards.

Albert

Mar 31 '07 #4

P: n/a

<al********@gmail.comwrote in message
news:11********************@e65g2000hsc.googlegrou ps.com...
In other words, by making it valid C++ and invalid C99.

What's your point?
My point is:
Maby the difference between VC++ in C++ mode and C99 is marginal.
No it's huge, even in this case where you use bool you will have to remove
stdbool.h references because VC++ doesnt supply the header. Thats not
C99....and theres way more C99 features that wont work no matter how you try
to run the compiler.

try and compile code like this:
struct S s = { .X = 2, .Y = 3, .Z = 4 };

Mar 31 '07 #5

P: n/a
try and compile code like this:
struct S s = { .X = 2, .Y = 3, .Z = 4 };
This does not even compile with EDG/C99.
Try it here
http://www.dinkumware.com/exam/
(Is any header required??)

Mar 31 '07 #6

P: n/a
'just relized that perhaps c_test.c
http://groups.google.at/group/comp.l...1a8816e8e87e3e
is not valid C99 after all!

c_test.c only compiles with EDG/C99 (http://www.dinkumware.com/exam/),
if line 14 looks like this
int size = INT_MAX / 10000;

Mar 31 '07 #7

P: n/a
On Mar 31, 2:06 pm, albert....@gmail.com wrote:
c_test.c only compiles with EDG/C99 (http://www.dinkumware.com/exam/),
if line 14 looks like this
int size = INT_MAX / 10000;
sorry (above post has an error);
I meant like this:
const int size = INT_MAX / 10000;

Mar 31 '07 #8

P: n/a

<al********@gmail.comwrote in message
news:11*********************@q75g2000hsh.googlegro ups.com...
>try and compile code like this:
struct S s = { .X = 2, .Y = 3, .Z = 4 };

This does not even compile with EDG/C99.
Try it here
http://www.dinkumware.com/exam/
(Is any header required??)
It's valid C99 nonetheless
Mar 31 '07 #9

P: n/a
<al********@gmail.comwrote in message
news:11**********************@n76g2000hsh.googlegr oups.com...
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.l...879cd6fca0acc8

To what extent does the latest VC++ (in C++ mode /TP) support C++ TR1?
Not at all.
To what extent does the latest VC++ (in C++ mode /TP) use Dinkumware
libraries?
We supply the Standard C++ library only, and have done so for over a
decade. But it is our earnest desire to license everything we have
to Microsoft, sooner or later. Note that the next revision of Standard
C++ will include all of the C99 library, as well as most of the rest
of TR1. To the extent that this creates demand from the public,
Microsoft might be interested in adding these features.

P.J. Plauger
Dinkumware, Ltd.
http://www.dinkumware.com
>

Mar 31 '07 #10

P: n/a

"P.J. Plauger" <pj*@dinkumware.comwrote in message
news:-M******************************@giganews.com...
>>
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.l...879cd6fca0acc8

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

Not at all.
>To what extent does the latest VC++ (in C++ mode /TP) use Dinkumware
libraries?

We supply the Standard C++ library only, and have done so for over a
decade. But it is our earnest desire to license everything we have
to Microsoft, sooner or later. Note that the next revision of Standard
C++ will include all of the C99 library, as well as most of the rest
of TR1. To the extent that this creates demand from the public,
Microsoft might be interested in adding these features.
If MS does, it might be that little push that C99 needs to be commonly
accepted. Personally I would love to see MSVC with full C99 support.
Mar 31 '07 #11

This discussion thread is closed

Replies have been disabled for this discussion.