Last Update 2020/12/09
-std=gnu99
言語標準をgnu99としてコンパイル
テスト概要
可変長配列、long long int、複合リテラル、typeofの使用を含むソースファイルのコンパイル
-std=オプションに c90 を指定してコンパイル実行
FAIL
可変長配列、long long int、複合リテラルに関する警告、typeofに関するエラー発生・停止
-std=オプションに c99 を指定してコンパイル実行
FAIL
typeofに関するエラー発生・停止
-std=オプションに gnu90 を指定してコンパイル実行
WARNING
警告のみでコンパイル終了・実行ファイル生成
-std=オプションに gnu99 を指定してコンパイル実行
PASS
コンパイル終了・実行ファイル生成
匿名構造体、typeofを使用したコードをコンパイル
-std=オプションに c99 を指定してコンパイル実行
FAIL
匿名構造体に関する警告、typeofに関するエラー発生・停止
-std=オプションに c11 を指定してコンパイル実行
FAIL
typeofに関するエラー発生・停止
-std=オプションに gnu99 を指定してコンパイル実行
WARNING
警告のみでコンパイル終了・実行ファイル生成
-std=オプションに gnu11 を指定してコンパイル実行
PASS
コンパイル終了・実行ファイル生成
実行環境
GCC-8.2.0
GNU C Library 2.28
GNU Binutils 2.31.1
GNU C Library 2.28
GNU Binutils 2.31.1
コード例・出力内容中の表記
・実行例中の太字表記部分は、コマンドなどの入力された文字列を示します。
・「︙」や「...」の着色省略表記は、 実際のソースコードや出力内容などを省略加工した部分を示します。
・「︙」や「...」の着色省略表記は、 実際のソースコードや出力内容などを省略加工した部分を示します。
使用ファイル
各例共通
sample.h
/* -std=gnu99 オプション動作確認用ヘッダファイル */
#ifndef SAMPLE_H
#define SAMPLE_H
int sampFunc(int n);
#endif /* SAMPLE_H */
main.c
/* -std=gnu99 オプション動作確認用ソースファイル main.c */
#include <stdio.h>
#include "sample.h"
int main(void)
{
int i;
typeof (int *) p; /* typeofの使用 */
i = 100;
p = &i;
int n = sampFunc(3);
printf("n = %d\n", n);
printf("*p = %d\n", *p);
return 0;
}
以下の項目を含むソースファイルのコンパイル
可変長配列
long long int
複合リテラル
typeofの使用
long long int
複合リテラル
typeofの使用
sample1.c
/* -std=gnu99 オプション動作確認用ソースファイル sample1.c */
#include <stdio.h>
#include "sample.h"
int sampFunc(int n)
{
int a[n]; /* 可変長配列 */
long long int i; /* long long int */
int j;
int *pn = (int []){4, 5, 6}; /* 複合リテラル */
for (i=0; i<n; i++)
{
a[i] = i * i;
}
for (i=0; i<n; i++)
{
for (j=0; j<3; j++)
{
printf("a[%d] = %d : b[%d] = %d\n", i, a[i], j, *(pn + j)) ;
}
}
return n;
}
-std=オプションに c90 を指定してコンパイル実行
$ gcc -v -std=c90 -Wpedantic sample1.c main.c <--- -WpedanticオプションでISO C で要求される警告を出力
Using built-in specs.
︙
/usr/libexec/gcc/x86_64-pc-linux-gnu/8.2.0/cc1 -quiet -v sample1.c ... -std=c90 ...
︙
GNU C89 (GCC) version 8.2.0 (x86_64-pc-linux-gnu) <--- 規格に関する出力(C89)
compiled by GNU C version 8.2.0, GMP version 6.1.2, MPFR version 4.0.1, MPC version 1.1.0, isl version none
︙
sample1.c: In function ‘sampFunc’:
sample1.c:8:2: warning: ISO C90 forbids variable length array ‘a’ [-Wvla]
int a[n]; 可変長配列に関する警告
^~~
sample1.c:9:7: warning: ISO C90 does not support ‘long long’ [-Wlong-long]
long long int i; long long int に関する警告
^~~~
sample1.c:12:20: warning: ISO C90 forbids compound literals [-Wpedantic]
int *pn = (int []){4, 5, 6}; 複合リテラル に関する警告
^
COLLECT_GCC_OPTIONS='-v' '-std=c90' '-Wpedantic' '-mtune=generic' '-march=x86-64'
as -v --64 -o /tmp/ccfgBzk3.o /tmp/ccnK667S.s
︙
/usr/libexec/gcc/x86_64-pc-linux-gnu/8.2.0/cc1 -quiet -v main.c ... -std=c90 ...
︙
main.c: In function ‘main’:
main.c:9:10: error: expected expression before ‘int’
typeof (int *) p; /* typeofの使用 */ 以下、typeofに関するエラー
^~~
main.c:9:16: error: expected ‘;’ before ‘p’
typeof (int *) p; /* typeofの使用 */
^~
;
main.c:12:2: error: ‘p’ undeclared (first use in this function)
p = &i;
^
main.c:12:2: note: each undeclared identifier is reported only once for each function it appears in
main.c:14:2: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
int n = sampFunc(3); C90の宣言とコードの混在に関する警告
^~~
$ エラー発生・停止
-std=オプションに c99 を指定してコンパイル実行
$ gcc -v -std=c99 -Wpedantic sample1.c main.c <--- -WpedanticオプションでISO C で要求される警告を出力
Using built-in specs.
︙
/usr/libexec/gcc/x86_64-pc-linux-gnu/8.2.0/cc1 -quiet -v sample1.c ... -std=c99 ...
︙
GNU C99 (GCC) version 8.2.0 (x86_64-pc-linux-gnu) <--- 規格に関する出力(C99)
compiled by GNU C version 8.2.0, GMP version 6.1.2, MPFR version 4.0.1, MPC version 1.1.0, isl version none
︙
as -v --64 -o /tmp/cc28ATS2.o /tmp/ccuWMWEL.s
︙
/usr/libexec/gcc/x86_64-pc-linux-gnu/8.2.0/cc1 -quiet -v main.c ... -std=c99 ...
︙
GNU C99 (GCC) version 8.2.0 (x86_64-pc-linux-gnu)
compiled by GNU C version 8.2.0, GMP version 6.1.2, MPFR version 4.0.1, MPC version 1.1.0, isl version none
︙
main.c: In function ‘main’:
main.c:9:2: warning: implicit declaration of function ‘typeof’; did you mean ‘feof’? [-Wimplicit-function-declaration]
typeof (int *) p; /* typeofの使用 */ 以下、typeofに関するエラー
^~~~~~
feof
main.c:9:10: error: expected expression before ‘int’
typeof (int *) p; /* typeofの使用 */
^~~
main.c:9:16: error: expected ‘;’ before ‘p’
typeof (int *) p; /* typeofの使用 */
^~
;
main.c:12:2: error: ‘p’ undeclared (first use in this function)
p = &i;
^
main.c:12:2: note: each undeclared identifier is reported only once for each function it appears in
$ エラー発生・停止
-std=オプションに gnu90 を指定してコンパイル実行
$ gcc -v -std=gnu90 -Wpedantic sample1.c main.c <--- -WpedanticオプションでISO C で要求される警告を出力
Using built-in specs.
︙
/usr/libexec/gcc/x86_64-pc-linux-gnu/8.2.0/cc1 -quiet -v sample1.c ... -std=gnu90 ...
︙
GNU C89 (GCC) version 8.2.0 (x86_64-pc-linux-gnu) <--- 規格に関する出力(C89)
compiled by GNU C version 8.2.0, GMP version 6.1.2, MPFR version 4.0.1, MPC version 1.1.0, isl version none
︙
sample1.c: In function ‘sampFunc’:
sample1.c:8:2: warning: ISO C90 forbids variable length array ‘a’ [-Wvla]
int a[n]; 可変長配列に関する警告
^~~
sample1.c:9:7: warning: ISO C90 does not support ‘long long’ [-Wlong-long]
long long int i; long long int に関する警告
^~~~
sample1.c:12:20: warning: ISO C90 forbids compound literals [-Wpedantic]
int *pn = (int []){4, 5, 6}; 複合リテラル に関する警告
^
COLLECT_GCC_OPTIONS='-v' '-std=gnu90' '-Wpedantic' '-mtune=generic' '-march=x86-64'
as -v --64 -o /tmp/ccRs5DnT.o /tmp/cczzGcQS.s
︙
/usr/libexec/gcc/x86_64-pc-linux-gnu/8.2.0/cc1 -quiet -v main.c ... -std=gnu90 ...
︙
main.c: In function ‘main’:
main.c:14:2: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]
int n = sampFunc(3); C90の宣言とコードの混在に関する警告
^~~
COLLECT_GCC_OPTIONS='-v' '-std=gnu90' '-Wpedantic' '-mtune=generic' '-march=x86-64'
as -v --64 -o /tmp/cc273M1T.o /tmp/cczzGcQS.s
︙
/usr/libexec/gcc/x86_64-pc-linux-gnu/8.2.0/collect2 ...
COLLECT_GCC_OPTIONS='-v' '-std=gnu90' '-Wpedantic' '-mtune=generic' '-march=x86-64'
$ ./a.out
a[0] = 0 : b[0] = 4
a[0] = 0 : b[1] = 5
a[0] = 0 : b[2] = 6
a[1] = 1 : b[0] = 4
a[1] = 1 : b[1] = 5
a[1] = 1 : b[2] = 6
a[2] = 4 : b[0] = 4
a[2] = 4 : b[1] = 5
a[2] = 4 : b[2] = 6
n = 3
*p = 100
$ 警告のみでコンパイル終了・実行ファイル生成
-std=オプションに gnu99 を指定してコンパイル実行
$ gcc -v -std=gnu99 -Wpedantic sample1.c main.c <--- -WpedanticオプションでISO C で要求される警告を出力
Using built-in specs.
︙
/usr/libexec/gcc/x86_64-pc-linux-gnu/8.2.0/cc1 -quiet -v sample1.c ... -std=gnu99 ...
︙
GNU C99 (GCC) version 8.2.0 (x86_64-pc-linux-gnu) <--- 規格に関する出力(C99)
compiled by GNU C version 8.2.0, GMP version 6.1.2, MPFR version 4.0.1, MPC version 1.1.0, isl version none
︙
as -v --64 -o /tmp/ccVLkQZd.o /tmp/ccnjq22p.s
︙
/usr/libexec/gcc/x86_64-pc-linux-gnu/8.2.0/cc1 -quiet -v main.c ... -std=gnu99 ...
︙
as -v --64 -o /tmp/ccPVn762.o /tmp/ccnjq22p.s
︙
/usr/libexec/gcc/x86_64-pc-linux-gnu/8.2.0/collect2 ...
COLLECT_GCC_OPTIONS='-v' '-std=gnu99' '-Wpedantic' '-mtune=generic' '-march=x86-64'
$ ./a.out
a[0] = 0 : b[0] = 4
a[0] = 0 : b[1] = 5
a[0] = 0 : b[2] = 6
a[1] = 1 : b[0] = 4
a[1] = 1 : b[1] = 5
a[1] = 1 : b[2] = 6
a[2] = 4 : b[0] = 4
a[2] = 4 : b[1] = 5
a[2] = 4 : b[2] = 6
n = 3
*p = 100
$ コンパイル終了・実行ファイル生成
匿名構造体、typeofを使用したコードをコンパイル
sample2.c
/* -std=gnu99 オプション動作確認用ソースファイル sample2.c */
#include <stdio.h>
#include "sample.h"
int sampFunc(int n)
{
struct
{
struct {int i1, i2;}; /* 匿名構造体 */
} sx;
sx.i1 = n * 2;
sx.i2 = n * 3;
printf("sx.i1 = %d : sx.i2 = %d\n", sx.i1, sx.i2);
return n;
}
-std=オプションに c99 を指定してコンパイル実行
$ gcc -v -std=c99 -Wpedantic sample2.c main.c <--- -WpedanticオプションでISO C で要求される警告を出力
Using built-in specs.
︙
/usr/libexec/gcc/x86_64-pc-linux-gnu/8.2.0/cc1 -quiet -v sample2.c ... -std=c99 ...
︙
GNU C99 (GCC) version 8.2.0 (x86_64-pc-linux-gnu) <--- 規格に関する出力(C99)
compiled by GNU C version 8.2.0, GMP version 6.1.2, MPFR version 4.0.1, MPC version 1.1.0, isl version none
︙
sample2.c: In function ‘sampFunc’:
sample2.c:10:23: warning: ISO C99 doesn’t support unnamed structs/unions [-Wpedantic]
struct {int i1, i2;}; 匿名構造体に関する警告
^
sample2.c:8:2: warning: struct has no named members [-Wpedantic]
struct
^~~~~~
COLLECT_GCC_OPTIONS='-v' '-std=c99' '-Wpedantic' '-mtune=generic' '-march=x86-64'
as -v --64 -o /tmp/ccDmLYc2.o /tmp/ccqbrKi2.s
︙
/usr/libexec/gcc/x86_64-pc-linux-gnu/8.2.0/cc1 -quiet -v main.c ... -std=c99 -version -o /tmp/ccqbrKi2.s
︙
main.c: In function ‘main’:
main.c:9:2: warning: implicit declaration of function ‘typeof’; did you mean ‘feof’? [-Wimplicit-function-declaration]
typeof (int *) p; /* typeofの使用 */ 以下、typeofに関するエラー
^~~~~~
feof
main.c:9:10: error: expected expression before ‘int’
typeof (int *) p; /* typeofの使用 */
^~~
main.c:9:16: error: expected ‘;’ before ‘p’
typeof (int *) p; /* typeofの使用 */
^~
;
main.c:12:2: error: ‘p’ undeclared (first use in this function)
p = &i;
^
main.c:12:2: note: each undeclared identifier is reported only once for each function it appears in
$ エラー発生・停止
-std=オプションに c11 を指定してコンパイル実行
$ gcc -v -std=c11 -Wpedantic sample2.c main.c <--- -WpedanticオプションでISO C で要求される警告を出力
Using built-in specs.
COLLECT_GCC=gcc
︙
/usr/libexec/gcc/x86_64-pc-linux-gnu/8.2.0/cc1 -quiet -v sample2.c ... -std=c11 ...
︙
GNU C11 (GCC) version 8.2.0 (x86_64-pc-linux-gnu) <--- 規格に関する出力(C99)
compiled by GNU C version 8.2.0, GMP version 6.1.2, MPFR version 4.0.1, MPC version 1.1.0, isl version none
︙
as -v --64 -o /tmp/ccAH3GCc.o /tmp/ccs1t26f.s
︙
/usr/libexec/gcc/x86_64-pc-linux-gnu/8.2.0/cc1 -quiet -v main.c ... -std=c11 ...
︙
main.c: In function ‘main’:
main.c:9:2: warning: implicit declaration of function ‘typeof’; did you mean ‘feof’? [-Wimplicit-function-declaration]
typeof (int *) p; /* typeofの使用 */ 以下、typeofに関するエラー
^~~~~~
feof
main.c:9:10: error: expected expression before ‘int’
typeof (int *) p; /* typeofの使用 */
^~~
main.c:9:16: error: expected ‘;’ before ‘p’
typeof (int *) p; /* typeofの使用 */
^~
;
main.c:12:2: error: ‘p’ undeclared (first use in this function)
p = &i;
^
main.c:12:2: note: each undeclared identifier is reported only once for each function it appears in
$ エラー発生・停止
-std=オプションに gnu99 を指定してコンパイル実行
$ gcc -v -std=gnu99 -Wpedantic sample2.c main.c <--- -WpedanticオプションでISO C で要求される警告を出力
Using built-in specs.
︙
/usr/libexec/gcc/x86_64-pc-linux-gnu/8.2.0/cc1 -quiet -v sample2.c ... -std=gnu99 ...
︙
GNU C99 (GCC) version 8.2.0 (x86_64-pc-linux-gnu) <--- 規格に関する出力(C99)
compiled by GNU C version 8.2.0, GMP version 6.1.2, MPFR version 4.0.1, MPC version 1.1.0, isl version none
︙
sample2.c: In function ‘sampFunc’:
sample2.c:10:23: warning: ISO C99 doesn’t support unnamed structs/unions [-Wpedantic]
struct {int i1, i2;}; 匿名構造体に関する警告
^
sample2.c:8:2: warning: struct has no named members [-Wpedantic]
struct
^~~~~~
COLLECT_GCC_OPTIONS='-v' '-std=gnu99' '-Wpedantic' '-mtune=generic' '-march=x86-64'
as -v --64 -o /tmp/ccYWNyks.o /tmp/ccxTDL6Q.s
︙
/usr/libexec/gcc/x86_64-pc-linux-gnu/8.2.0/cc1 -quiet -v main.c ... -std=gnu99 ...
︙
as -v --64 -o /tmp/ccrxhVI4.o /tmp/ccxTDL6Q.s
︙
/usr/libexec/gcc/x86_64-pc-linux-gnu/8.2.0/collect2 ...
COLLECT_GCC_OPTIONS='-v' '-std=gnu99' '-Wpedantic' '-mtune=generic' '-march=x86-64'
$ ./a.out
sx.i1 = 6 : sx.i2 = 9
n = 3
*p = 100
$ 警告のみでコンパイル終了・実行ファイル生成
-std=オプションに gnu11 を指定してコンパイル実行
$ gcc -v -std=gnu11 -Wpedantic sample2.c main.c <--- -WpedanticオプションでISO C で要求される警告を出力
Using built-in specs.
︙
/usr/libexec/gcc/x86_64-pc-linux-gnu/8.2.0/cc1 -quiet -v sample2.c ... -std=gnu11 ...
︙
GNU C11 (GCC) version 8.2.0 (x86_64-pc-linux-gnu) <--- 規格に関する出力(C99)
compiled by GNU C version 8.2.0, GMP version 6.1.2, MPFR version 4.0.1, MPC version 1.1.0, isl version none
︙
as -v --64 -o /tmp/ccDJ1aar.o /tmp/ccxMKi4m.s
︙
/usr/libexec/gcc/x86_64-pc-linux-gnu/8.2.0/cc1 -quiet -v main.c ... -std=gnu11 ...
︙
as -v --64 -o /tmp/ccKPluqw.o /tmp/ccxMKi4m.s
︙
/usr/libexec/gcc/x86_64-pc-linux-gnu/8.2.0/collect2 ...
COLLECT_GCC_OPTIONS='-v' '-std=gnu11' '-Wpedantic' '-mtune=generic' '-march=x86-64'
$ ./a.out
sx.i1 = 6 : sx.i2 = 9
n = 3
*p = 100
$ コンパイル終了・実行ファイル生成