jedisct1 / libhydrogen

A lightweight, secure, easy-to-use crypto library suitable for constrained environments.
https://libhydrogen.org
Other
594 stars 88 forks source link

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

Closed edmonds closed 4 months ago

edmonds commented 4 months ago

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"
      |                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~