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>
This commit is contained in:
Erik Verbruggen
2014-03-12 13:55:09 +01:00
committed by Erik Verbruggen
parent 6206dc8b64
commit ae24a88e90

View File

@@ -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.