相关疑难解决方法(0)

当前gcc的默认C模式是什么(特别是在Ubuntu上)?

当我要求查看cc的当前版本时,我得到了这个.

$ cc --version
cc (Ubuntu/Linaro 4.7.2-2ubuntu1) 4.7.2
Copyright (C) 2012 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ 
Run Code Online (Sandbox Code Playgroud)

我想知道的是使用c89,c90,c99或c11中的哪一个.

c ubuntu gcc c99 c11

51
推荐指数
3
解决办法
3万
查看次数

警告:ISO C90禁止混合声明和代码[-Wdeclaration-after-statement]

我有这个c文件

#include <stdio.h>

int main(int argc, char *argv[])
{
  int x,i,sum;
  sum = 0;
  FILE *fin;
  fin = fopen("testdata1", "r");


    for (i = 0; i < 20; i++ ){
      fscanf(fin, "%d", &x);
      sum += x;
    }

    printf("Sum = %d", sum);
    fclose(fin);
    return 0;


}
Run Code Online (Sandbox Code Playgroud)

我通过编译它 gcc -ansi -pedantic -Wall app.c -o app

在编译时,我不断收到此警告错误

警告:ISO C90禁止混合声明和代码[-Wdeclaration-after-statement] FILE*fin; 生成^ 1警告.

有关如何阻止它的任何提示?

c c89

2
推荐指数
1
解决办法
7074
查看次数

由于数组,ISO C90禁止混合声明和代码.我该如何解决?

我尝试使用-gcc它编译它,它按预期工作,但添加时-pedantic,它将无法编译.我还是编程的初学者,这是我第一次遇到这个问题所以对我来说这是一个很大的问题.

以下是导致错误的代码:

char *exercise[5]={"swimming", "running", "brisk walking", "weight lifting", "zumba"};
Run Code Online (Sandbox Code Playgroud)

如果您能解释解决方案的内容而不仅仅是固定代码,我会很感激,因为我想学习.

c arrays compiler-errors gcc-pedantic

1
推荐指数
1
解决办法
1万
查看次数

标签 统计

c ×3

arrays ×1

c11 ×1

c89 ×1

c99 ×1

compiler-errors ×1

gcc ×1

gcc-pedantic ×1

ubuntu ×1