From a5f3a76e14799c68b5e8f74e375baa5f6f6ab4dc Mon Sep 17 00:00:00 2001 From: Kevin Funk Date: Thu, 29 Dec 2016 12:23:20 +0100 Subject: Pass -fno-operator-names when supported Summary: Disables alternative tokens for &&, ||, etc.. They're are not supported by MSVC out of the box, thus using them will limit the portability of the code. There *are* options to make alternative tokens available under MSVC [1], but I think we shouldn't promote the usage of them. From the GCC documentation: -fno-operator-names: Do not treat the operator name keywords and, bitand, bitor, compl, not, or and xor as synonyms as keywords. [1] http://stackoverflow.com/questions/555505/when-were-the-and-and-or-alternative-tokens-introduced-in-c Reviewers: #frameworks, #buildsystem, ivan Reviewed By: ivan Subscribers: rakuco, elvisangelaccio Differential Revision: https://phabricator.kde.org/D3850 --- kde-modules/KDECompilerSettings.cmake | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'kde-modules/KDECompilerSettings.cmake') diff --git a/kde-modules/KDECompilerSettings.cmake b/kde-modules/KDECompilerSettings.cmake index 24eea3a7..583dfb57 100644 --- a/kde-modules/KDECompilerSettings.cmake +++ b/kde-modules/KDECompilerSettings.cmake @@ -211,6 +211,14 @@ if (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-common") endif() +# Do not treat the operator name keywords and, bitand, bitor, compl, not, or and xor as synonyms as keywords. +# They're not supported under Visual Studio out of the box thus using them limits the portability of code +if (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR + CMAKE_C_COMPILER_ID STREQUAL "Clang" OR + (CMAKE_C_COMPILER_ID STREQUAL "Intel" AND NOT WIN32)) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-operator-names") +endif() + # Default to hidden visibility for symbols set(CMAKE_C_VISIBILITY_PRESET hidden) set(CMAKE_CXX_VISIBILITY_PRESET hidden) -- cgit v1.2.1