通过使用“C ++模式”对C99的Visual C ++支持(/ TP) [英] Visual C++ support of C99 by using "C++ mode" (/TP)

查看:82
本文介绍了通过使用“C ++模式”对C99的Visual C ++支持(/ TP)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在多大程度上

Microsoft Visual C ++
也称为:VC ++

也称为:Microsoft(R)32位C / C ++优化编译器


支持C99?

VC ++编译为C模式(def。*不是* C99!):

cl.exe / TC c_file.c

或C ++模式

cl.exe / TP cpp_file.cpp


在C模式(/ TC)中,VC ++肯定是*不符合C99!



但是一个有趣的问题是:

当在C ++模式(/ TP)中使用时,VC ++与C99的一致性如何?


考虑到
$ b时,这一点特别有趣$ b C99库是C ++ TR1的一部分。
http://groups.google.at/group/comp.l...879cd6fca0acc8


到什么最新的VC ++(在C ++模式/ TP中)是否支持C ++ TR1?

最新VC ++(在C ++模式/ TP中)使用Dinkumware

库的程度如何?



以下是有效的C99代码:


/ ************* c_test.c *************** /

#include< stdio.h>

#include< stdbool.h>

#include< limits.h>


int main(无效)

{

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);


返回0;

}

上面的C99代码可以在VC ++上编译,只需评论第二个

行(见下文!)


/ ************* 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\\\
",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);


返回0;

}


用VC ++编译:

cl.exe \TP cpp_test.cpp


工作完美!嗯...差不多C99 ...... ???


评论赞赏,

Albert



注意:

Microsoft VC ++编译器可以免费获得:

" Visual C ++" ;:Microsoft(R)32-bit C $ C ++优化编译器


搜索
http://www.microsoft.com/downloads

for

Microsoft Windows SDK for Windows Vista

On下载页面;检查系统要求:

例如

Windows XP Professional SP2(OK!),Windows Vista等。

(否则搜索另一个兼容的Microsoft Windows SDK)


安装后:

环境变量的批处理可以如下所示:

C:\Program Files \ Microsoft Office SDK \ Windows \\\\\\\\\\\\\\\\\\\\\\\\\ /

发布/ x86 / xp

在setenv.cmd:

''颜色07''是黑色的正常白色


编译器在这里:

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

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

推荐答案

al **** **** @gmail.com 写道:

以下是有效的C99代码:


/ ************* c_test.c *************** /

#include< stdio.h>

#include< stdbool.h>

#include< limits.h>


int main(void)

{

bool b = true;

if(b)

printf(" hello world\\\
) ;


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);


返回0;

}


上面的C99代码可以在VC ++上编译,只需注释第二行

行(见下文!)
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!)



换句话说,通过使它成为有效的C ++和无效的C99。


你的意思是什么?

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

What''s your point?


al ******** @ gmail.com 说:

在多大程度上

Microsoft Visual C ++
也称为:VC ++

也叫:Microsoft(R)32位C / C ++优化编译器


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

support C99?



因为Visual C支持C90,它实际上支持大部分C99

(因为大部分C99基本上都是C90),但是它没有声明C99

一致性。微软也没有表示对支持C99的支出感兴趣,直到他们的大部分客户需要支付C99(这似乎不会在短期内发生) )。


< snip>


-

Richard Heathfield

Usenet是一个奇怪的地方 - dmr 29/7/1999
http://www.cpax.org.uk

电子邮件:rjh在上述域名中, - www。

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.


3月31日下午1:20,Harald van D?3k < true ... @ gmail.comwrote:
On Mar 31, 1:20 pm, "Harald van D?3k" <true...@gmail.comwrote:

albert .... @ gmail.com写道:
albert....@gmail.com wrote:

以下是有效的C99代码:
The following is valid C99 code:


/ ************* c_test.c ** ************* /

#include< stdio.h>

#include< stdbool.h>

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


int main(void)

{

bool b = true;

if(b)

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


char c = 5;

printf("%hhd \ n",c);
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);
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);


返回0;

}
return 0;
}


上面的C99代码可以在VC ++上编译,只需注释第二个

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



换句话说,使其成为有效的C ++和无效的C99。


你的意思是什么?


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

What''s your point?



我的观点是:

Maby C ++模式下VC ++与C99之间的差异很小。

(在上面的示例中,只有当前VC +

+中不知道标题(但无论如何都支持bool))


和maby这个差异会得到甚至更小,如果VC ++采用(或者更接近b $ b符合)更新的C ++标准。


Albert

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


这篇关于通过使用“C ++模式”对C99的Visual C ++支持(/ TP)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆