build: Reject C++ compilers in the preprocessor

This commit is contained in:
Tim Ruffing 2022-03-17 22:26:19 +01:00
parent 1cc0941414
commit 3b4f3d0d46
2 changed files with 14 additions and 4 deletions

View File

@ -312,10 +312,9 @@ task:
name: "C++ -fpermissive" name: "C++ -fpermissive"
<< : *LINUX_CONTAINER << : *LINUX_CONTAINER
env: env:
# ./configure correctly errors out when given CC=g++. CC: g++
# We hack around this by passing CC=g++ only to make. CFLAGS: -fpermissive -g
CC: gcc CPPFLAGS: -DSECP256K1_CPLUSPLUS_TEST_OVERRIDE
MAKEFLAGS: -j4 CC=g++ CFLAGS=-fpermissive\ -g
WERROR_CFLAGS: WERROR_CFLAGS:
EXPERIMENTAL: yes EXPERIMENTAL: yes
ECDH: yes ECDH: yes

View File

@ -4,6 +4,17 @@
* file COPYING or https://www.opensource.org/licenses/mit-license.php.* * file COPYING or https://www.opensource.org/licenses/mit-license.php.*
***********************************************************************/ ***********************************************************************/
/* This is a C project. It should not be compiled with a C++ compiler,
* and we error out if we detect one.
*
* We still want to be able to test the project with a C++ compiler
* because it is still good to know if this will lead to real trouble, so
* there is a possibility to override the check. But be warned that
* compiling with a C++ compiler is not supported. */
#if defined(__cplusplus) && !defined(SECP256K1_CPLUSPLUS_TEST_OVERRIDE)
#error Trying to compile a C project with a C++ compiler.
#endif
#define SECP256K1_BUILD #define SECP256K1_BUILD
#include "../include/secp256k1.h" #include "../include/secp256k1.h"