Skip to content

[C++] Fix runtime version macro references - #4998

Open
catlove3 wants to merge 1 commit into
antlr:devfrom
catlove3:fix-cpp-version-macros
Open

catlove3 wants to merge 1 commit into
antlr:devfrom
catlove3:fix-cpp-version-macros

Conversation

@catlove3

Copy link
Copy Markdown

ANTLRCPP_VERSION and ANTLRCPP_VERSION_STRING reference undefined ANTLR4CPP_VERSION_* macros instead of the defined ANTLRCPP_VERSION_* macros. This makes the numeric version fail to compile when used as a C++ expression, while the version string and RuntimeMetaData::getRuntimeVersion() return literal macro names instead of a version such as 4.13.2.

Correct the six version-component references in Version.h. Add a compile-time assertion for the numeric version and a regression test covering the version string, RuntimeMetaData::VERSION, and getRuntimeVersion(). Expected values are derived from the version components so the tests continue to work after version bumps.

Validation:

  • Reproduced the numeric compilation failure and the string regression test failure before the fix.
  • Built the C++ runtime and antlr4_tests with GCC 13.3, C++17, and a Debug static-library build.
  • All 65 CTest tests pass after the fix.

Fixes #4393

Signed-off-by: zypcat <191636042@qq.com>
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.

[C++] Invalid version string

1 participant