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

hydrogen.h: Add #ifndef __cplusplus guard for pragma not valid in C++ #150

Merged
merged 1 commit into from
Mar 4, 2024
Merged

hydrogen.h: Add #ifndef __cplusplus guard for pragma not valid in C++ #150

merged 1 commit into from
Mar 4, 2024

Conversation

edmonds
Copy link
Contributor

@edmonds edmonds commented Mar 3, 2024

This commit wraps the GCC pragma to ignore -Wdeclaration-after-statement diagnostics in an #ifndef __cplusplus guard since this pragma isn't needed when compiling in C++ mode.

Without this change, I get the following diagnostic from g++ when compiling a C++ project that includes hydrogen.h:

../subprojects/libhydrogen/hydrogen.h:11:32: warning: option ‘-Wdeclaration-after-statement’ is valid for C/ObjC but not for C++ [-Wpragmas]
   11 | #pragma GCC diagnostic ignored "-Wdeclaration-after-statement"
      |                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This commit wraps the GCC pragma to ignore -Wdeclaration-after-statement
diagnostics in an `#ifndef __cplusplus` guard since this pragma isn't
needed when compiling in C++ mode.

Without this change, I get the following diagnostic from g++ when
compiling a C++ project that includes hydrogen.h:

    ../subprojects/libhydrogen/hydrogen.h:11:32: warning: option ‘-Wdeclaration-after-statement’ is valid for C/ObjC but not for C++ [-Wpragmas]
       11 | #pragma GCC diagnostic ignored "-Wdeclaration-after-statement"
          |                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@jedisct1 jedisct1 merged commit f8a43eb into jedisct1:master Mar 4, 2024
6 checks passed
@edmonds edmonds deleted the cplusplus-invalid-diagnostics branch March 4, 2024 00:34
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.

2 participants