Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

変数名の省略によるコンパイルエラー #1

Closed
sgtm0113 opened this issue May 10, 2022 · 1 comment · Fixed by #2
Closed

変数名の省略によるコンパイルエラー #1

sgtm0113 opened this issue May 10, 2022 · 1 comment · Fixed by #2

Comments

@sgtm0113
Copy link

sgtm0113 commented May 10, 2022

このコードをコンパイルしようとした際、以下のエラーでコンパイルできませんでした。

sugi@Z690:~/jquery-practice$ gcc main.c 
In file included from main.c:2:
jquery.h: In function ‘appendTo’:
jquery.h:125:15: error: parameter name omitted
  125 | void appendTo(char*) {
      |               ^~~~~

該当の行の変数に適当な名前(sなど)をつけてあげると正常にコンパイル・実行できました。gcc std=c17などいくつかの規格を試しましたが、元のコードではコンパイルできませんでした。環境は以下の通りです。

sugi@Z690:~/jquery-practice$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/9/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:hsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 9.4.0-1ubuntu1~20.04.1' --with-bugurl=file:///usr/share/doc/gcc-9/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,gm2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-9 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/gcc-9-Av3uEd/gcc-9-9.4.0/debian/tmp-nvptx/usr,hsa --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 9.4.0 (Ubuntu 9.4.0-1ubuntu1~20.04.1) 
wataash added a commit to wataash/jquery-practice that referenced this issue May 11, 2022
@wataash wataash mentioned this issue May 11, 2022
@yanorei32
Copy link
Owner

関数の使用されていない引数名の省略は、規格化途中の C2X extension (omitted parameter names for C2x) により許可されているものでした。

私が検証に用いていたCコンパイラは何れもC2Xに対応し、標準で有効であった為気づきませんでした。

  • gcc (Ubuntu 11.2.0-19ubuntu1) 11.2.0
  • Ubuntu clang version 14.0.0-1ubuntu1

C2Xの為に要求バージョンを上げるのも申し訳ないので、@wataash 氏の Pull-Request (#2) を Review / Merge する方針で対応したいと思います。

コンパイラの対応状況

https://godbolt.org/ にて得られた各コンパイラの対応状況は以下の通りです。

f(int){}
compiler version
clang ✅ 11.0.0 or newer
gcc ✅ 11.1 or newer
icx
icc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants