0. Introduction
- This article speaks several ways to compile on gcc,
- You may wish to set up a file called
test.c
1. A method
$ gcc test.c
- (Windows OS) compiler successful, there is no feedback, in
test.c
case the folder where you will add aa.exe
- Operation method: to a respective path, choose one of the following
2. Method Two
2.1 a written
$ gcc -o test test.c
2.2 writing two
$ gcc test.c -o test
- As the effect of two kinds of writing
- If successful, the
test.c
next folder where you will add atest.exe
3. Method Three
3.1 a written
$ gcc -std=c99 -o test test.c
3.2 writing two
$ gcc -std=c99 test.c -o test
- As the effect of two kinds of writing
- The wording specified C Standard: C99, to specify other criteria, can be
-std=xxx
4. About C99
#include <stdio.h>
int main()
{
int a[13] = {[1]=2, 4, [5]=6}; // C99 的特性,定义数组时可以指定特定的位置
for(int i=0; i<13; i++) // C11 可用,ANSI C 不行
{
printf("a[%d] = %d\n", i, a[i]);
}
return 0;
}
$ gcc test.c -o test // 会报错
$ gcc -std=c99 test.c -o test // 这样才行