From ae24a88e90b03e252169bedf4fec42185644634d Mon Sep 17 00:00:00 2001 From: Erik Verbruggen <erik.verbruggen@me.com> Date: Wed, 12 Mar 2014 13:55:09 +0100 Subject: [PATCH] Clang: never include a define for __cplusplus. The flags used by the project explorer to interrogate the toolchain for compiler-defined #defines always indicate a C++ file. So, this will always include a #define for __cplusplus. When editing C code with the clang code model, this results in extern "C" linkage specifications, which result in warnings or errors. The proper fix is described in QTCREATORBUG-11709, but is too big to be done within the 3.1 timeframe. Task-number: QTCREATORBUG-11501 Change-Id: Id9e261fa8d429fead4a2cd5fd7398aa6e1e8c13d Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com> --- src/plugins/clangcodemodel/clangutils.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/plugins/clangcodemodel/clangutils.cpp b/src/plugins/clangcodemodel/clangutils.cpp index dae5f1a835c..79348e44bd8 100644 --- a/src/plugins/clangcodemodel/clangutils.cpp +++ b/src/plugins/clangcodemodel/clangutils.cpp @@ -113,6 +113,11 @@ static QStringList buildDefines(const QByteArray &defines, bool toolchainDefines if (def.isEmpty()) continue; + // This is a quick fix for QTCREATORBUG-11501. + // TODO: do a proper fix, see QTCREATORBUG-11709. + if (def.startsWith("#define __cplusplus")) + continue; + // TODO: verify if we can pass compiler-defined macros when also passing -undef. if (toolchainDefines) { //### FIXME: the next 3 check shouldn't be needed: we probably don't want to get the compiler-defined defines in. -- GitLab