0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

unknown argument と invalid value . 今日のclang error(27)

Last updated at Posted at 2019-09-02

「github入門」の入門
https://qiita.com/kaizen_nagoya/items/b6f5b1532fd21fec79c8

記事を一歩すすめるためshell scriptをあげた。
https://github.com/kaizen-nagoya/hello-world/blob/master/gccl.sh

「Cの可変長引数とABIの奇妙な関係」のコメントにあげていただいたプログラムをdockerで
https://qiita.com/kaizen_nagoya/items/79e771ff681fb27f6070

で書いたものを、もう一歩だけ汎用化しようとした。

しかし、よく考えたら、スクリプトのパラメータを飛ばして入力することはできなさそう。
エスケープシーケンス入れるのはまだ試していない。

差し障りがなさそうは、 -Wall, -std=c99 などを入れようと思って試して見た。

docker/gcc

# ./gccl.sh hoge -Wall -std:1998 gcc clang --version
https://qiita.com/qnighy/items/be04cfe57f8874121e76
https://qiita.com/kaizen_nagoya/items/79e771ff681fb27f6070
$ clang hoge.c -Wall  -std:1998 -o hogel
clang: error: unknown argument: '-std:1998'
1.200000 3

$ gcc hoge.c -Wall -std:1998 -o hogeg
gcc: error: unrecognized command line option '-std:1998'
1.200000 3

gcc (GCC) 9.1.0
Copyright (C) 2019 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.

clang version 7.0.1-8 (tags/RELEASE_701/final)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin

調べずにいいかげんに-std:1998としたら怒られた。2000年問題前だから、2桁の数字だったっけと思い出して入れてみた。

docker/gcc
# ./gccl.sh hoge -Wall -std=98 gcc clang --version
https://qiita.com/qnighy/items/be04cfe57f8874121e76
https://qiita.com/kaizen_nagoya/items/79e771ff681fb27f6070
$ clang hoge.c -Wall  -std=98 -o hogel
error: invalid value '98' in '-std=98'
note: use 'c89', 'c90', or 'iso9899:1990' for 'ISO C 1990' standard
note: use 'iso9899:199409' for 'ISO C 1990 with amendment 1' standard
note: use 'gnu89' or 'gnu90' for 'ISO C 1990 with GNU extensions' standard
note: use 'c99' or 'iso9899:1999' for 'ISO C 1999' standard
note: use 'gnu99' for 'ISO C 1999 with GNU extensions' standard
note: use 'c11' or 'iso9899:2011' for 'ISO C 2011' standard
note: use 'gnu11' for 'ISO C 2011 with GNU extensions' standard
note: use 'c17' or 'iso9899:2017' for 'ISO C 2017' standard
note: use 'gnu17' for 'ISO C 2017 with GNU extensions' standard


$ gcc hoge.c -Wall -std=98 -o hogeg
gcc: error: unrecognized command line option '-std=98'; did you mean '-std=c18'?

gcc (GCC) 9.1.0
Copyright (C) 2019 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.

:じゃなくて=だってわかった。

docker/gcc
# ./gccl.sh hoge -Wall -std=c18 gcc clang --version
https://qiita.com/qnighy/items/be04cfe57f8874121e76
https://qiita.com/kaizen_nagoya/items/79e771ff681fb27f6070
$ clang hoge.c -Wall  -std=c18 -o hogel
error: invalid value 'c18' in '-std=c18'
note: use 'c89', 'c90', or 'iso9899:1990' for 'ISO C 1990' standard
note: use 'iso9899:199409' for 'ISO C 1990 with amendment 1' standard
note: use 'gnu89' or 'gnu90' for 'ISO C 1990 with GNU extensions' standard
note: use 'c99' or 'iso9899:1999' for 'ISO C 1999' standard
note: use 'gnu99' for 'ISO C 1999 with GNU extensions' standard
note: use 'c11' or 'iso9899:2011' for 'ISO C 2011' standard
note: use 'gnu11' for 'ISO C 2011 with GNU extensions' standard
note: use 'c17' or 'iso9899:2017' for 'ISO C 2017' standard
note: use 'gnu17' for 'ISO C 2017 with GNU extensions' standard
1.200000 3

$ gcc hoge.c -Wall -std=c18 -o hogeg
1.200000 3

gccの方しかみてなくてc18にしたけどclangの方はc17って書いているのに。失敗。

docker/gcc
# ./gccl.sh hoge -Wall -std=c17 gcc clang --version
https://qiita.com/qnighy/items/be04cfe57f8874121e76
https://qiita.com/kaizen_nagoya/items/79e771ff681fb27f6070
$ clang hoge.c -Wall  -std=c17 -o hogel
1.200000 3

$ gcc hoge.c -Wall -std=c17 -o hogeg
1.200000 3
gcc (GCC) 9.1.0
Copyright (C) 2019 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.

clang version 7.0.1-8 (tags/RELEASE_701/final)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin

Reference

Error一覧 error(0)
https://qiita.com/kaizen_nagoya/items/48b6cbc8d68eae2c42b8

<この記事は個人の過去の経験に基づく個人の感想です。現在所属する組織、業務とは関係がありません。>
This article is an individual impression based on the individual's experience. It has nothing to do with the organization or business to which I currently belong.

文書履歴(document history)

ver. 0.01 初稿  20240504

最後までおよみいただきありがとう4ざいました。

いいね 💚、フォローをお願いします。

Thank you very much for reading to the last sentence.

Please press the like icon 💚 and follow me for your happy life.;://cv

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?