Skip to content

Make the GCC deprecation-message check actually test the GCC version - #355

Open
Chang-Jin-Lee wants to merge 1 commit into
KhronosGroup:mainfrom
Chang-Jin-Lee:fix/336-undefined-gcc-version
Open

Chang-Jin-Lee wants to merge 1 commit into
KhronosGroup:mainfrom
Chang-Jin-Lee:fix/336-undefined-gcc-version

Conversation

@Chang-Jin-Lee

Copy link
Copy Markdown

Fixes #336.

GCC_VERSION is not predefined by GCC, so #if GCC_VERSION >= 40500 has always compared 0 against 40500 and taken the branch below it. Every deprecated symbol in the public header loses its message on GCC:

warning: ‘spvReflectGetShaderModule’ is deprecated [-Wdeprecated-declarations]

and with this change it reads

warning: ‘spvReflectGetShaderModule’ is deprecated: renamed to spvReflectCreateShaderModule [-Wdeprecated-declarations]

-Wundef names the cause on its own: "GCC_VERSION" is not defined, evaluates to 0, at spirv_reflect.h:49. Clang and MSVC were never affected, since they are handled by the branches above.

The issue suggests defining GCC_VERSION. I spelled the comparison out instead — this is a public header, and GCC_VERSION is a common enough spelling in other projects that defining it here could collide with a consumer's own. The >= 40500 gate is left alone rather than dropped, so the intent of the original code is unchanged.

Checked on GCC 13.3.0: the message appears in C and in C++ under -Wall -Wextra, the -Wundef warning is gone, and test-spirv-reflect is 3678 passing. The edit sits inside the file's clang-format off region, so the formatting job has nothing to reflow.

🤖 Generated with Claude Code

GCC_VERSION is not a predefined macro, so `#if GCC_VERSION >= 40500` compared
0 against 40500 and always took the branch below it.  Every deprecated symbol
in the public header therefore lost its message on GCC:

  warning: 'spvReflectGetShaderModule' is deprecated [-Wdeprecated-declarations]

instead of

  warning: 'spvReflectGetShaderModule' is deprecated: renamed to
  spvReflectCreateShaderModule [-Wdeprecated-declarations]

`-Wundef` reports it directly: "GCC_VERSION is not defined, evaluates to 0".

Spelled the version comparison out rather than defining GCC_VERSION, because
this is a public header and that name is common enough in other projects to
collide.

Fixes KhronosGroup#336

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@spencer-lunarg

Copy link
Copy Markdown
Contributor

@Chang-Jin-Lee can you make sure the CLA is signed for this repo so I can merge this

(if you did, try https://cla-assistant.io/ to retrigger it)

@Chang-Jin-Lee

Copy link
Copy Markdown
Author

Sorry for the slow reply. The CLA is mine to clear and it is still unsigned — license/cla is the only thing not green here, everything else passed. I am going through the signing flow now and will retrigger it as you suggested once it is done.

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 this pull request may close these issues.

GCC_VERSION used in spirv_reflect.h but is undefined

3 participants