C ++与C兼容? [英] C++ compatible with C ?
问题描述
我可以假设如果一个.c文件用gcc编译好了它也会编译
ok,扩展名为.cc扩展名吗?
任意例如这不起作用?
问候,
jjleto
Can I assume that if a .c file compiles ok with gcc it will also compile
ok with a .cc extension with g++ ?
Any example where this does not work ?
regards,
jjleto
推荐答案
jjleto写道:
我可以假设如果一个.c文件用gcc编译好了它还可以用g ++编译好.cc扩展名吗?
绝对没有。
这个不起作用的例子吗?
Can I assume that if a .c file compiles ok with gcc it will also compile
ok with a .cc extension with g++ ?
Absolutely not.
Any example where this does not work ?
当然,一个明显的例子是在C ++中有一些关键字
不是C中的关键字。
编译类似:
int class ;
Sure, one obvious example is that there are a few keywords in C++ that
aren''t keywords in C.
Compile something like:
int class;
jjleto写道:
我可以假设如果一个.c文件用gcc编译好,它也会编译
使用带有g ++的.cc扩展名吗?
这不起作用的任何例子?
我现在还不记得gcc处理评论的严格程度,但
有这个古老的例子
#v +
[...]
int i;
i = 8 // * Harhar * / 2
;
[...]
#v-
问候,
jjleto
Can I assume that if a .c file compiles ok with gcc it will also compile
ok with a .cc extension with g++ ?
Any example where this does not work ?
I do not remember at the moment how strict gcc handles comments, but
there was this old example of
#v+
[...]
int i;
i = 8 //* Harhar */ 2
;
[...]
#v-
regards,
jjleto
>
问候,
约翰内斯
-
#macro s(a,b)sphere {< a,b,20> .3pigment {color x}}#end light_source {-4 * x 1}
#macro q(a)(a * a)#end #local C = -1 ; #while(C <1)s(512 *(11 * C-9)/ q(121 * C * C-198 *
C + 97)-4,4.22 *(3- 11 * C)/(exp(C * 11/4)+2.12)+ 11 * C-8.5)s(4-.15 * exp(3.3 * C),12 /
5- 11 * C / 2)s(4-16 *(q(C * C)-C * C),4 * C + 7/2)s(2 * C-6,7.5)#local C = C + .01 ;#end // JB
Greeting,
Johannes
--
#macro s(a,b)sphere{<a,b,20>.3pigment{color x}}#end light_source{-4*x 1}
#macro q(a)(a*a)#end#local C=-1;#while(C<1)s(512*(11*C-9)/q(121*C*C-198*
C+97)-4,4.22*(3-11*C)/(exp(C*11/4)+2.12)+11*C-8.5)s(4-.15*exp(3.3*C),12/
5-11*C/2)s(4-16*(q(C*C)-C*C),4*C+7/2)s(2*C-6,7.5)#local C=C+.01;#end//JB
文章< 41 *********************** @ news.wanadoo.fr>,
jjleto< jj **** @ laposte.net>写道:
In article <41***********************@news.wanadoo.fr>,
jjleto <jj****@laposte.net> wrote:
我可以假设,如果一个.c文件用gcc编译好,它也会编译
确定用。+扩展名与g ++?
No.
任何不起作用的例子?
Can I assume that if a .c file compiles ok with gcc it will also compile
ok with a .cc extension with g++ ?
No.
Any example where this does not work ?
明显的例子:
int old,new; / *有效C,无效C ++ * /
更微妙的例子:
--------
# include< stdio.h>
int main(无效)
{
int i = 42 // ** /
+7;
if(i == 49)
if(sizeof''a''== 1)
puts(C ++编译器或异常字节大小);
else / * //注释和'a''是int * /
#if定义(__ STDC_VERSION__ )&& __STDC_VERSION__> = 199901L
puts(C99编译器);
#else
puts(破碎的C89编译器);
#endif
else
puts(C89编译器);
返回0 ;
}
--------
dave @ goofy:〜/ clc(0)
Obvious example:
int old,new; /*Valid C, invalid C++*/
More subtle example:
--------
#include <stdio.h>
int main(void)
{
int i=42//**/
+7;
if(i==49)
if(sizeof ''a'' == 1)
puts("C++ compiler or unusual byte size");
else /* // comments and ''a'' is int*/
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
puts("C99 compiler");
#else
puts("broken C89 compiler");
#endif
else
puts("C89 compiler");
return 0;
}
--------
dave@goofy:~/clc (0)
这篇关于C ++与C兼容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!