0

In CMakelists.txt, I have:

cmake_minimum_required(VERSION 3.1)
set(CMAKE_CXX_STANDARD 14)

if(WIN32)
    set(CMAKE_CXX_FLAGS "/EHsc")
else()
    set(CMAKE_CXX_FLAGS -m64)
endif()

I verified that in visual studio, it is in fact running c++14, by doing these steps

I have the following flags enabled:

set(COMMON_FLAGS -Wfloat-conversion -Wsign-compare -Wsign-conversion -Wbitfield-enum-conversion -Wshorten-64-to-32 -Wstring-conversion -Werror -Wall -Wextra)

I get many errors like this when I try to build in visual studio. From debugging, I know that they are thrown by -Wall:

error : 'constexpr' specifier is incompatible with C++98 [-Werror,-Wc++98-compat]
error : 'long long' is incompatible with C++98 [-Werror,-Wc++98-compat-pedantic]
error : use of this statement in a constexpr function is incompatible with C++ standards before C++14 [-Werror,-Wc++98-c++11-compat]

Questions:

  1. Why are c++98 errors thrown when I am running c++14?
  2. Why do these errors not get thrown when I am running the same project in linux, using the same CMakelists.txt? (On windows I am running clang 7.0.0, and on windows I am running clang 5.0.1)
Preethi Vaidyanathan
  • 1,203
  • 1
  • 12
  • 32
  • `-Wall` should trigger those warnings (turned into errors). I think `clang`s `-Weverything` has been activated somehow. Add `-Wno-c++98-compat -Wno-c++98-compat-pedantic` to `COMMON_FLAGS` to see if that helps. The `COMMON_FLAGS` must be last on the final command line when executing it though. – Ted Lyngmo Jul 05 '22 at 22:39
  • “Why do these errors not get thrown on Linux” Clang on windows ultimately uses msvc behind the scenes. So you aren’t comparing apples to apples. – Taekahn Jul 05 '22 at 22:49
  • Correction: "_`-Wall` should **not** trigger those warnings ..."_ ... – Ted Lyngmo Jul 05 '22 at 22:57

0 Answers0