Tell to Meson to compile C files with CXX compiler #11603
-
In certain cases, like for example, compiling Catch2 tests with a C language file, you need to tell the compiler to use the C++ compiler to compile the C files (instead of using the CC compiler). In CMake is easily done with I tried already setting the language to |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 5 replies
-
Does the C language file contain C++ code defining the tests? If so, why not name it .cpp instead? If it truly only contains C code but is needed in the binary along with a .cpp file containing the test definition, then is it not sufficient to link both the C functions and the C++ test definitions together using a C++ linker? Meson will do that automatically for targets that contain a mixture of C and C++ source files. |
Beta Was this translation helpful? Give feedback.
-
Another option would be (useful if the files belong to some other project and you can't rename them) to |
Beta Was this translation helpful? Give feedback.
-
Another option would be to include a C language for the project, but pass |
Beta Was this translation helpful? Give feedback.
Does the C language file contain C++ code defining the tests? If so, why not name it .cpp instead?
If it truly only contains C code but is needed in the binary along with a .cpp file containing the test definition, then is it not sufficient to link both the C functions and the C++ test definitions together using a C++ linker? Meson will do that automatically for targets that contain a mixture of C and C++ source files.