diff options
author | Ray Molenkamp <github@lazydodo.com> | 2020-02-12 22:49:34 +0300 |
---|---|---|
committer | Ray Molenkamp <github@lazydodo.com> | 2020-02-12 22:49:34 +0300 |
commit | 9fe469c110940af5d2525158305d5d365bd15276 (patch) | |
tree | 3944557e2117fbe67c1ee5bfcd793bc5d3b9a96c /intern | |
parent | dd9dfadaac9b17d0a5f41545925668717b662b08 (diff) |
Cleanup/MSVC: Enable C++ conformance mode on compiler versions that support it.
MSVC has a conformance mode (/permissive-) where the C++ standard is more strictly
enforced. This mode is available on MSVC 15.5+ [1]
This patch enables this mode on compilers that support it and cleans up the few violations it threw up in the process.
- Mantaflow was using M_PI without requesting them using the _USE_MATH_DEFINES define to opt in to non default behaviour.
- Collada did not include the right header for std::cerr, this seemingly was fixed for other platforms already but put inside a platform guard.
- Ghost had some scoping issues regarding uninitialized variables and goto behaviour
[1] https://docs.microsoft.com/en-us/cpp/build/reference/permissive-standards-conformance
Differential Revision: https://developer.blender.org/D6824
Reviewed By: brecht
Diffstat (limited to 'intern')
-rw-r--r-- | intern/ghost/intern/GHOST_ContextWGL.cpp | 24 | ||||
-rw-r--r-- | intern/mantaflow/CMakeLists.txt | 5 |
2 files changed, 19 insertions, 10 deletions
diff --git a/intern/ghost/intern/GHOST_ContextWGL.cpp b/intern/ghost/intern/GHOST_ContextWGL.cpp index d4851450ce8..6d5d4f75351 100644 --- a/intern/ghost/intern/GHOST_ContextWGL.cpp +++ b/intern/ghost/intern/GHOST_ContextWGL.cpp @@ -647,9 +647,11 @@ GHOST_TSuccess GHOST_ContextWGL::initializeDrawingContext() /* Silence warnings interpreted as errors by users when trying to get * a context with version higher than 3.3 Core. */ - const bool silent = m_contextMajorVersion > 3; - if (!WIN32_CHK_SILENT(m_hGLRC != NULL, silent)) { - goto error; + { + const bool silent = m_contextMajorVersion > 3; + if (!WIN32_CHK_SILENT(m_hGLRC != NULL, silent)) { + goto error; + } } s_sharedCount++; @@ -680,15 +682,17 @@ GHOST_TSuccess GHOST_ContextWGL::initializeDrawingContext() ::SwapBuffers(m_hDC); #ifndef NDEBUG - const char *vendor = reinterpret_cast<const char *>(glGetString(GL_VENDOR)); - const char *renderer = reinterpret_cast<const char *>(glGetString(GL_RENDERER)); - const char *version = reinterpret_cast<const char *>(glGetString(GL_VERSION)); + { + const char *vendor = reinterpret_cast<const char *>(glGetString(GL_VENDOR)); + const char *renderer = reinterpret_cast<const char *>(glGetString(GL_RENDERER)); + const char *version = reinterpret_cast<const char *>(glGetString(GL_VERSION)); - reportContextString("Vendor", m_dummyVendor, vendor); - reportContextString("Renderer", m_dummyRenderer, renderer); - reportContextString("Version", m_dummyVersion, version); + reportContextString("Vendor", m_dummyVendor, vendor); + reportContextString("Renderer", m_dummyRenderer, renderer); + reportContextString("Version", m_dummyVersion, version); - fprintf(stderr, "Context Version: %d.%d\n", m_contextMajorVersion, m_contextMinorVersion); + fprintf(stderr, "Context Version: %d.%d\n", m_contextMajorVersion, m_contextMinorVersion); + } #endif return GHOST_kSuccess; diff --git a/intern/mantaflow/CMakeLists.txt b/intern/mantaflow/CMakeLists.txt index 2d49f96a451..b2a0ab30a0c 100644 --- a/intern/mantaflow/CMakeLists.txt +++ b/intern/mantaflow/CMakeLists.txt @@ -30,6 +30,11 @@ if(WITH_OPENVDB) add_definitions(-DOPENVDB_STATICLIB) endif() +if(WIN32) + add_definitions(-D_USE_MATH_DEFINES) +endif() + + set(INC extern intern/strings |