BLI_strict_flags.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*
  2. * ***** BEGIN GPL LICENSE BLOCK *****
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License
  6. * as published by the Free Software Foundation; either version 2
  7. * of the License, or (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software Foundation,
  16. * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  17. *
  18. * ***** END GPL LICENSE BLOCK *****
  19. */
  20. #ifndef __BLI_STRICT_FLAGS_H__
  21. #define __BLI_STRICT_FLAGS_H__
  22. /** \file BLI_strict_flags.h
  23. * \ingroup bli
  24. * \brief Strict compiler flags for areas of code we want
  25. * to ensure don't do conversions without us knowing about it.
  26. */
  27. #ifdef __GNUC__
  28. # if (__GNUC__ * 100 + __GNUC_MINOR__) >= 406 /* gcc4.6+ only */
  29. # pragma GCC diagnostic error "-Wsign-compare"
  30. # endif
  31. # if __GNUC__ >= 6 /* gcc6+ only */
  32. # pragma GCC diagnostic error "-Wconversion"
  33. # endif
  34. # if (__GNUC__ * 100 + __GNUC_MINOR__) >= 408
  35. /* gcc4.8+ only (behavior changed to ignore globals)*/
  36. # pragma GCC diagnostic error "-Wshadow"
  37. /* older gcc changed behavior with ternary */
  38. # pragma GCC diagnostic error "-Wsign-conversion"
  39. # endif
  40. /* pedantic gives too many issues, developers can define this for own use */
  41. # ifdef WARN_PEDANTIC
  42. # pragma GCC diagnostic error "-Wpedantic"
  43. # ifdef __clang__ /* pedantic causes clang error */
  44. # pragma GCC diagnostic ignored "-Wlanguage-extension-token"
  45. # endif
  46. # endif
  47. #endif
  48. #ifdef _MSC_VER
  49. # pragma warning(error:4018) /* signed/unsigned mismatch */
  50. # pragma warning(error:4244) /* conversion from 'type1' to 'type2', possible loss of data */
  51. # pragma warning(error:4245) /* conversion from 'int' to 'unsigned int' */
  52. # pragma warning(error:4267) /* conversion from 'size_t' to 'type', possible loss of data */
  53. # pragma warning(error:4305) /* truncation from 'type1' to 'type2' */
  54. # pragma warning(error:4389) /* signed/unsigned mismatch */
  55. #endif
  56. #endif /* __BLI_STRICT_FLAGS_H__ */