aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVolker-Weissmann <39418860+Volker-Weissmann@users.noreply.github.com>2021-05-19 16:10:22 +0200
committerGitHub <noreply@github.com>2021-05-19 17:10:22 +0300
commit4ca9a16288f51cce99624a2ef595d879acdc02d8 (patch)
treeac6d15bc04257135fb65927be64bc9eb0de9c140
parenta6e9b54b1d2d16b723e9aefd8cf49558e68abdc3 (diff)
downloadmeson-4ca9a16288f51cce99624a2ef595d879acdc02d8.zip
meson-4ca9a16288f51cce99624a2ef595d879acdc02d8.tar.gz
meson-4ca9a16288f51cce99624a2ef595d879acdc02d8.tar.bz2
.C files are now treated as C++ code
-rw-r--r--mesonbuild/compilers/compilers.py6
-rw-r--r--mesonbuild/mesonlib/universal.py10
-rw-r--r--test cases/common/2 cpp/cpp.C6
-rw-r--r--test cases/common/2 cpp/meson.build7
4 files changed, 23 insertions, 6 deletions
diff --git a/mesonbuild/compilers/compilers.py b/mesonbuild/compilers/compilers.py
index 9b4418b..231eca7 100644
--- a/mesonbuild/compilers/compilers.py
+++ b/mesonbuild/compilers/compilers.py
@@ -51,7 +51,7 @@ lib_suffixes = ('a', 'lib', 'dll', 'dll.a', 'dylib', 'so') # type: T.Tuple[str,
# This means we can't include .h headers here since they could be C, C++, ObjC, etc.
lang_suffixes = {
'c': ('c',),
- 'cpp': ('cpp', 'cc', 'cxx', 'c++', 'hh', 'hpp', 'ipp', 'hxx', 'ino', 'ixx'),
+ 'cpp': ('cpp', 'cc', 'cxx', 'c++', 'hh', 'hpp', 'ipp', 'hxx', 'ino', 'ixx', 'C'),
'cuda': ('cu',),
# f90, f95, f03, f08 are for free-form fortran ('f90' recommended)
# f, for, ftn, fpp are for fixed-form fortran ('f' or 'for' recommended)
@@ -510,7 +510,9 @@ class Compiler(metaclass=abc.ABCMeta):
def can_compile(self, src: 'mesonlib.FileOrString') -> bool:
if isinstance(src, mesonlib.File):
src = src.fname
- suffix = os.path.splitext(src)[1].lower()
+ suffix = os.path.splitext(src)[1]
+ if suffix != '.C':
+ suffix = suffix.lower()
return bool(suffix) and suffix[1:] in self.can_compile_suffixes
def get_id(self) -> str:
diff --git a/mesonbuild/mesonlib/universal.py b/mesonbuild/mesonlib/universal.py
index ee1152c..318b365 100644
--- a/mesonbuild/mesonlib/universal.py
+++ b/mesonbuild/mesonlib/universal.py
@@ -350,10 +350,12 @@ class FileMode:
return perms
dot_C_dot_H_warning = """You are using .C or .H files in your project. This is deprecated.
- Currently, Meson treats this as C code, but this
- might change in the future, breaking your build.
- You code also might be already broken on gcc and clang.
- See https://github.com/mesonbuild/meson/pull/8239 for the discussions."""
+ Currently, Meson treats this as C++ code, but they
+ used to be treated as C code.
+ Note that the situation is a bit more complex if you are using the
+ Visual Studio compiler, as it treats .C files as C code, unless you add
+ the /TP compiler flag, but this is unreliable.
+ See https://github.com/mesonbuild/meson/pull/8747 for the discussions."""
class File:
def __init__(self, is_built: bool, subdir: str, fname: str):
if fname.endswith(".C") or fname.endswith(".H"):
diff --git a/test cases/common/2 cpp/cpp.C b/test cases/common/2 cpp/cpp.C
new file mode 100644
index 0000000..d3df476
--- /dev/null
+++ b/test cases/common/2 cpp/cpp.C
@@ -0,0 +1,6 @@
+#include<iostream>
+
+int main(void) {
+ std::cout << "C++ seems to be working." << std::endl;
+ return 0;
+}
diff --git a/test cases/common/2 cpp/meson.build b/test cases/common/2 cpp/meson.build
index 47cb7c5..8f13d66 100644
--- a/test cases/common/2 cpp/meson.build
+++ b/test cases/common/2 cpp/meson.build
@@ -32,3 +32,10 @@ else
endif
assert(exe_disabled, 'Executable was not disabled.')
+
+if cpp.get_id() == 'msvc'
+ exe = executable('cppprog', 'cpp.C', cpp_args : '/TP')
+else
+ exe = executable('cppprog', 'cpp.C')
+endif
+test('cpptest', exe)