Commit 77c89ff8 by Ben Clayton

Build: Verify that we're compiling with C++14.

Better to have a descriptive compiler error message than weird missing symbols. Bug: b/147359661 Change-Id: I66c0e5beb1e94f79210528867c990ab3e0f8b0ae Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/39949Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com> Kokoro-Presubmit: kokoro <noreply+kokoro@google.com> Tested-by: 's avatarBen Clayton <bclayton@google.com>
parent 3cc0aeae
...@@ -1768,6 +1768,7 @@ file(GLOB VULKAN_LIST ...@@ -1768,6 +1768,7 @@ file(GLOB VULKAN_LIST
${VULKAN_DIR}/*.cpp ${VULKAN_DIR}/*.cpp
${VULKAN_DIR}/*.h ${VULKAN_DIR}/*.h
${VULKAN_DIR}/*.hpp ${VULKAN_DIR}/*.hpp
${SOURCE_DIR}/System/Build.cpp
${SOURCE_DIR}/System/Build.hpp ${SOURCE_DIR}/System/Build.hpp
${SOURCE_DIR}/System/CPUID.cpp ${SOURCE_DIR}/System/CPUID.cpp
${SOURCE_DIR}/System/CPUID.hpp ${SOURCE_DIR}/System/CPUID.hpp
......
...@@ -571,6 +571,7 @@ cc_defaults { ...@@ -571,6 +571,7 @@ cc_defaults {
], ],
srcs: [ srcs: [
"System/Build.cpp",
"System/CPUID.cpp", "System/CPUID.cpp",
"System/Configurator.cpp", "System/Configurator.cpp",
"System/Half.cpp", "System/Half.cpp",
......
...@@ -36,6 +36,7 @@ swiftshader_source_set("System_headers") { ...@@ -36,6 +36,7 @@ swiftshader_source_set("System_headers") {
swiftshader_source_set("System") { swiftshader_source_set("System") {
sources = [ sources = [
"Build.cpp",
"CPUID.cpp", "CPUID.cpp",
"Configurator.cpp", "Configurator.cpp",
"Debug.cpp", "Debug.cpp",
......
// Copyright 2020 The SwiftShader Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#if defined(_MSVC_LANG)
# define CPP_VERSION _MSVC_LANG
#elif defined(__cplusplus)
// Note: This must come after checking for _MSVC_LANG.
// See https://developercommunity.visualstudio.com/content/problem/139261/msvc-incorrectly-defines-cplusplus.html
# define CPP_VERSION __cplusplus
#endif
#if !defined(CPP_VERSION) || CPP_VERSION <= 1
# error "Unable to identify C++ language version"
#endif
// The template and dummy function below verifies the compiler is using at least
// C++14. It will print an error message containing the actual C++ version if
// the version is < 14.
namespace {
template<int version>
class cpp
{
static_assert(version >= 2014, "SwiftShader requires at least C++14");
};
void check_cpp_version()
{
cpp<CPP_VERSION / 100>();
(void)&check_cpp_version; // dummy reference to avoid unreferenced function warning.
}
} // namespace
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment