From 4ca9a16288f51cce99624a2ef595d879acdc02d8 Mon Sep 17 00:00:00 2001 From: Volker-Weissmann <39418860+Volker-Weissmann@users.noreply.github.com> Date: Wed, 19 May 2021 16:10:22 +0200 Subject: .C files are now treated as C++ code --- mesonbuild/compilers/compilers.py | 6 ++++-- mesonbuild/mesonlib/universal.py | 10 ++++++---- 2 files changed, 10 insertions(+), 6 deletions(-) (limited to 'mesonbuild') 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"): -- cgit v1.1