C99便携性挑战 [英] C99 portability challenge
问题描述
这个群体中有几个人认为标准C
不可携带,因为它没有编译器等等。
我建议使用这个程序标准C,我在几个操作系统中编译了
来测试这是否真的如此。我的
基本思路是看哪些系统没有编译器
支持标准C.
程序设计生成自然
整数的总和,直到用户提供者参数。例如
电话
总和55
应该产生
前55个整数的总和是1540。
-------------------------------------- ---------在这里切割
#include< stdio.h>
#include< stdlib.h>
int main(int argc,char * argv [])
{
int sum = 0;
if(argc < 2){
printf(" Usage:sum< number> \ n");
返回1;
}
int top = atoi(argv [1]);
if(top< = 0)
返回0;
if(前100名){
printf("最大值100.输入较低的值\ n);
返回1;
}
int vla [top];
for(int i = 0 ; i< top; i ++){
vla [i] = i + 1;
}
for(int j = 0; j< top; j ++){
sum + = vla [j];
}
printf(" ;第一个%d整数的总和i s%d \ n",top,sum);
返回0;
}
--------- ---------------------------------------在这里切割
我已经成功编译了这个程序
(1):windows使用lcc-win。
(2):linux使用gcc -std = c99
(3):AIX使用xlc
我没有任何其他类型的系统可用。如果你有一个上面没有列出的系统,请
尝试编译
这个。
提前致谢。
-
jacob navia
jacob at jacob point remcomp point fr
logiciels / informatique
http://www.cs.virginia.edu/~lcc-win32
Several people in this group argue that standard C
is not portable since there are no compilers for it, etc.
I propose this program in Standard C, that I have compiled
in several OSes to test if this is actually true. My
basic idea is to see which systems do not have a compiler that
supports standard C.
The program is designed to produce the sum of the natural
integers up to a user provider argument. For instance
the call
sum 55
should produce
The sum of the first 55 integers is 1540.
-----------------------------------------------cut here
#include <stdio.h>
#include <stdlib.h>
int main(int argc,char *argv[])
{
int sum=0;
if (argc < 2) {
printf("Usage: sum <number>\n");
return 1;
}
int top = atoi(argv[1]);
if (top <= 0)
return 0;
if (top 100) {
printf("Maximum value 100. Enter a lower value\n");
return 1;
}
int vla[top];
for (int i=0; i<top;i++) {
vla[i] = i+1;
}
for (int j = 0; j<top;j++) {
sum += vla[j];
}
printf("The sum of the first %d integers is %d\n",top,sum);
return 0;
}
------------------------------------------------cut here
I have already successfully compiled this program under
(1): windows using lcc-win.
(2): linux using gcc -std=c99
(3): AIX using xlc
I do not have any other type of system available. Please
if you have a system not listed above try to compile
this.
Thanks in advance.
--
jacob navia
jacob at jacob point remcomp point fr
logiciels/informatique
http://www.cs.virginia.edu/~lcc-win32
推荐答案
Jensen Somers写道:
Jensen Somers wrote:
您好,
jacob navia写道:
< snip>
Hello,
jacob navia wrote:
<snip>
>>
我已经成功编译了这个程序
(1):windows使用lcc-win。
(2):linux使用gcc -std = c99
(3):AIX使用xlc
我没有任何其他类型的系统可用。如果您有上面未列出的系统,请尝试编译
。
提前致谢。
>>
I have already successfully compiled this program under
(1): windows using lcc-win.
(2): linux using gcc -std=c99
(3): AIX using xlc
I do not have any other type of system available. Please
if you have a system not listed above try to compile
this.
Thanks in advance.
应用程序无法在Windows上使用Visual Studio 2005和
Visual Studio 2008进行编译。
使用C模式(/ TC)进行编译时,应用程序无法编译到期'
''int top'',''int i''以及任何其他变量
声明不在函数开头的声明。我相信这个
是默认的C90行为。
使用C ++模式(/ TP)进行编译时,应用程序无法编译,因为
''int vla [top]''的声明因为''top''不是一个常量的
表达式,它无法创建一个常量大小为0的数组。
- Jensen
The application fails to compile on Windows using Visual Studio 2005 and
Visual Studio 2008.
When compiling using C mode (/TC) the application fails to compile due
to the declaration of ''int top'', ''int i'' and any other variable
declaration that is not at the beginning of the function. I believe this
is default C90 behavior.
When compiling using C++ mode (/TP) the application fails to compile due
to the declaration of ''int vla[top]'' because ''top'' is not a constant
expression and it is unable to create an array of constant size 0.
- Jensen
您可以在Visual Studio中使用英特尔编译器,因此支持C99在Windows下的
。 lcc-win也支持C99,而gcc(mingw)也用在那里
,所以windows系统都是卖的。
-
jacob navia
jacob at jacob point remcomp point fr
logiciels / informatique
http://www.cs.virginia.edu/~lcc-win32
jacob navia写道:
jacob navia wrote:
这个群体中有几个人认为标准C
不可移植,因为没有编译器对于它等等。
我在标准C中提出这个程序,我在几个操作系统中编译了
来测试这是否真的如此。我的
基本思路是看哪些系统没有编译器
支持标准C.
程序设计生成自然
整数的总和,直到用户提供者参数。例如
电话
总和55
应该产生
前55个整数的总和是1540。
-------------------------------------- ---------在这里切割
#include< stdio.h>
#include< stdlib.h>
int main(int argc,char * argv [])
{
int sum = 0;
if(argc < 2){
printf(" Usage:sum< number> \ n");
返回1;
}
int top = atoi(argv [1]);
if(top< = 0)
返回0;
if(前100名){
printf("最大值100.输入较低的值\ n);
返回1;
}
int vla [top];
for(int i = 0 ; i< top; i ++){
vla [i] = i + 1;
}
for(int j = 0; j< top; j ++){
sum + = vla [j];
}
printf("第一个%d个整数的总和是%d \ n,top ,总和);
返回0;
}
------------------ ------------------------------在这里切换
我已经成功编译了这个程序下
(1):windows使用lcc-win。
(2):linux使用gcc -std = c99
(3):AIX使用xlc
Several people in this group argue that standard C
is not portable since there are no compilers for it, etc.
I propose this program in Standard C, that I have compiled
in several OSes to test if this is actually true. My
basic idea is to see which systems do not have a compiler that
supports standard C.
The program is designed to produce the sum of the natural
integers up to a user provider argument. For instance
the call
sum 55
should produce
The sum of the first 55 integers is 1540.
-----------------------------------------------cut here
#include <stdio.h>
#include <stdlib.h>
int main(int argc,char *argv[])
{
int sum=0;
if (argc < 2) {
printf("Usage: sum <number>\n");
return 1;
}
int top = atoi(argv[1]);
if (top <= 0)
return 0;
if (top 100) {
printf("Maximum value 100. Enter a lower value\n");
return 1;
}
int vla[top];
for (int i=0; i<top;i++) {
vla[i] = i+1;
}
for (int j = 0; j<top;j++) {
sum += vla[j];
}
printf("The sum of the first %d integers is %d\n",top,sum);
return 0;
}
------------------------------------------------cut here
I have already successfully compiled this program under
(1): windows using lcc-win.
(2): linux using gcc -std=c99
(3): AIX using xlc
(4):FreeBSD使用gcc -std = c99
-
Pietro Cerutti
(4): FreeBSD using gcc -std=c99
--
Pietro Cerutti
8月26日凌晨4点07分,jacob navia< ja ... @ nospam.comwrote:
On Aug 26, 4:07*am, jacob navia <ja...@nospam.comwrote:
这个群体中有几个人认为标准C
不可携带,因为没有编译器,等等。
我在标准C中提出这个程序,我在几个操作系统中编译了
来测试这是否真的如此。我的
基本思路是看哪些系统没有编译器
支持标准C.
程序设计生成自然
整数的总和,直到用户提供者参数。比如
电话
* * * *总和55
应该产生
前55的总和整数是1540.
---------------------------------- -------------在这里切割
#include< stdio.h>
#include< stdlib.h>
int main(int argc,char * argv [])
{
* * * * int sum = 0;
>
* * * * if(argc< 2){
* * * * * * * * printf(" Usage:sum< number> \ n");
* * * * * * * *返回1;
* * * *}
* * * * int top = atoi(argv [1]);
* * * * if(top< = 0)
* * * * * * * * return 0;
* * * * if(前100名){
* * * * * * * * printf("最大值100.输入较低的值\ n");
* * * * * * * *返回1;
* * * *}
* * * * int vla [top];
* * * * for(int i = 0; i< top; i ++){
* * * * * * * * vla [i] = i + 1;
* * * *}
* * * * for(int j = 0; j< top; j ++){
* * * * * * * * sum + = vla [j];
* * * *}
* * * * printf("第一个%d个整数的总和是%d \ n,top,sum);
* * * *返回0; }
------------------------------------- -----------在这里剪切
我已经成功编译了这个程序
(1):windows使用lcc-win。
(2):linux使用gcc -std = c99
(3):AIX使用xlc
我没有任何其他类型的系统。如果你有一个上面没有列出的系统,请
尝试编译
这个。
提前致谢。
-
jacob navia
jacob at jacob point remcomp point fr
logiciels / informatiquehttp:// www .cs.virginia.edu / ~lcc-win32
Several people in this group argue that standard C
is not portable since there are no compilers for it, etc.
I propose this program in Standard C, that I have compiled
in several OSes to test if this is actually true. My
basic idea is to see which systems do not have a compiler that
supports standard C.
The program is designed to produce the sum of the natural
integers up to a user provider argument. For instance
the call
* * * * sum 55
should produce
The sum of the first 55 integers is 1540.
-----------------------------------------------cut here
#include <stdio.h>
#include <stdlib.h>
int main(int argc,char *argv[])
{
* * * * int sum=0;
* * * * if (argc < 2) {
* * * * * * * * printf("Usage: sum <number>\n");
* * * * * * * * return 1;
* * * * }
* * * * int top = atoi(argv[1]);
* * * * if (top <= 0)
* * * * * * * * return 0;
* * * * if (top 100) {
* * * * * * * * printf("Maximum value 100. Enter a lower value\n");
* * * * * * * * return 1;
* * * * }
* * * * int vla[top];
* * * * for (int i=0; i<top;i++) {
* * * * * * * * vla[i] = i+1;
* * * * }
* * * * for (int j = 0; j<top;j++) {
* * * * * * * * sum += vla[j];
* * * * }
* * * * printf("The sum of the first %d integers is %d\n",top,sum);
* * * * return 0;}
------------------------------------------------cut here
I have already successfully compiled this program under
(1): windows using lcc-win.
(2): linux using gcc -std=c99
(3): AIX using xlc
I do not have any other type of system available. Please
if you have a system not listed above try to compile
this.
Thanks in advance.
--
jacob navia
jacob at jacob point remcomp point fr
logiciels/informatiquehttp://www.cs.virginia.edu/~lcc-win32
我无法访问我的FreeBSD和Linux盒子,
但是这里我有一个旧版本的gcc:
----- 8< ---------- 8< ---------- 8< ---------- 8< -----
[XXXXXXXX @ XXXXXXX~
I don''t have access to my FreeBSD and Linux boxes,
but here I have an old version of gcc:
-----8<----------8<----------8<----------8<-----
[XXXXXXXX@XXXXXXX ~
这篇关于C99便携性挑战的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!