| 1 |
/* |
| 2 |
* BuildSettingsCompiler.h |
| 3 |
* ----------------------- |
| 4 |
* Purpose: Global compiler setting overrides |
| 5 |
* Notes : (currently none) |
| 6 |
* Authors: OpenMPT Devs |
| 7 |
* The OpenMPT source code is released under the BSD license. Read LICENSE for more details. |
| 8 |
*/ |
| 9 |
|
| 10 |
|
| 11 |
#pragma once |
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
#include "mpt/base/detect_compiler.hpp" |
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
// compiler configuration |
| 20 |
|
| 21 |
#if MPT_COMPILER_MSVC |
| 22 |
|
| 23 |
#pragma warning(default:4800) // Implicit conversion from 'int' to bool. Possible information loss |
| 24 |
|
| 25 |
#pragma warning(disable:4355) // 'this' : used in base member initializer list |
| 26 |
|
| 27 |
// happens for immutable classes (i.e. classes containing const members) |
| 28 |
#pragma warning(disable:4512) // assignment operator could not be generated |
| 29 |
|
| 30 |
#pragma warning(error:4309) // Treat "truncation of constant value"-warning as error. |
| 31 |
#pragma warning(error:4463) // Treat overflow; assigning value to bit-field that can only hold values from low_value to high_value"-warning as error. |
| 32 |
|
| 33 |
#ifdef MPT_BUILD_ANALYZED |
| 34 |
// Disable Visual Studio static analyzer warnings that generate too many false positives in VS2010. |
| 35 |
//#pragma warning(disable:6246) |
| 36 |
//#pragma warning(disable:6262) |
| 37 |
#pragma warning(disable:6297) // 32-bit value is shifted, then cast to 64-bit value. Results might not be an expected value. |
| 38 |
#pragma warning(disable:6326) // Potential comparison of a constant with another constant |
| 39 |
//#pragma warning(disable:6385) |
| 40 |
//#pragma warning(disable:6386) |
| 41 |
#endif // MPT_BUILD_ANALYZED |
| 42 |
|
| 43 |
#endif // MPT_COMPILER_MSVC |
| 44 |
|
| 45 |
#if MPT_COMPILER_GCC |
| 46 |
|
| 47 |
#ifdef MPT_COMPILER_SETTING_QUIRK_GCC_BROKEN_IPA |
| 48 |
// See <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115049>. |
| 49 |
#if MPT_GCC_BEFORE(9, 0, 0) |
| 50 |
// Earlier GCC get confused about setting a global function attribute. |
| 51 |
// We need to check for 9.0 instead of 9.1 because of |
| 52 |
// <https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1028580>. |
| 53 |
// It also gets confused when setting global optimization -O1, |
| 54 |
// so we have no way of fixing GCC 8 or earlier. |
| 55 |
//#pragma GCC optimize("O1") |
| 56 |
#else |
| 57 |
#pragma GCC optimize("no-ipa-ra") |
| 58 |
#endif |
| 59 |
#endif // MPT_COMPILER_SETTING_QUIRK_GCC_BROKEN_IPA |
| 60 |
|
| 61 |
#endif // MPT_COMPILER_GCC |
| 62 |
|
| 63 |
#if MPT_COMPILER_CLANG |
| 64 |
|
| 65 |
#if defined(MPT_BUILD_MSVC) |
| 66 |
#pragma clang diagnostic warning "-Wimplicit-fallthrough" |
| 67 |
#endif // MPT_BUILD_MSVC |
| 68 |
|
| 69 |
#if defined(MODPLUG_TRACKER) |
| 70 |
#pragma clang diagnostic ignored "-Wunused-local-typedef" |
| 71 |
#endif // MODPLUG_TRACKER |
| 72 |
|
| 73 |
#endif // MPT_COMPILER_CLANG |