Macros.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. /*
  2. * Copyright 2010 SRI International
  3. *
  4. * This program is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU Lesser General Public License as published by
  6. * the Free Software Foundation, either version 3 of the License, or
  7. * (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 Lesser General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Lesser General Public License
  15. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. #ifndef OPEN_KARTO_MACROS_H
  18. #define OPEN_KARTO_MACROS_H
  19. ////////////////////////////////////////////////////////////////////////////////////////
  20. ////////////////////////////////////////////////////////////////////////////////////////
  21. ////////////////////////////////////////////////////////////////////////////////////////
  22. /**
  23. * Karto defines for handling deprecated code
  24. */
  25. #ifndef KARTO_DEPRECATED
  26. # if defined(__GNUC__) && (__GNUC__ >= 4 || (__GNUC__ == 3 && __GNUC_MINOR__>=1))
  27. # define KARTO_DEPRECATED __attribute__((deprecated))
  28. # elif defined(__INTEL) || defined(_MSC_VER)
  29. # define KARTO_DEPRECATED __declspec(deprecated)
  30. # else
  31. # define KARTO_DEPRECATED
  32. # endif
  33. #endif
  34. ////////////////////////////////////////////////////////////////////////////////////////
  35. ////////////////////////////////////////////////////////////////////////////////////////
  36. ////////////////////////////////////////////////////////////////////////////////////////
  37. /**
  38. * Karto defines for windows dynamic build
  39. */
  40. #if defined(_MSC_VER) || defined(__CYGWIN__) || defined(__MINGW32__) || defined( __BCPLUSPLUS__) || defined( __MWERKS__)
  41. # if defined( _LIB ) || defined( KARTO_STATIC ) || defined( STATIC_BUILD )
  42. # define KARTO_EXPORT
  43. # else
  44. # ifdef KARTO_DYNAMIC
  45. # define KARTO_EXPORT __declspec(dllexport)
  46. # else
  47. # define KARTO_EXPORT __declspec(dllimport)
  48. # endif // KARTO_DYNAMIC
  49. # endif
  50. #else
  51. # define KARTO_EXPORT
  52. #endif
  53. ////////////////////////////////////////////////////////////////////////////////////////
  54. ////////////////////////////////////////////////////////////////////////////////////////
  55. ////////////////////////////////////////////////////////////////////////////////////////
  56. /**
  57. * Helper defines for std iterator loops
  58. */
  59. #define forEach( listtype, list ) \
  60. for ( listtype::iterator iter = (list)->begin(); iter != (list)->end(); ++iter )
  61. #define forEachAs( listtype, list, iter ) \
  62. for ( listtype::iterator iter = (list)->begin(); iter != (list)->end(); ++iter )
  63. #define const_forEach( listtype, list ) \
  64. for ( listtype::const_iterator iter = (list)->begin(); iter != (list)->end(); ++iter )
  65. #define const_forEachAs( listtype, list, iter ) \
  66. for ( listtype::const_iterator iter = (list)->begin(); iter != (list)->end(); ++iter )
  67. #define forEachR( listtype, list ) \
  68. for ( listtype::reverse_iterator iter = (list)->rbegin(); iter != (list)->rend(); ++iter )
  69. #define const_forEachR( listtype, list ) \
  70. for ( listtype::const_reverse_iterator iter = (list)->rbegin(); iter != (list)->rend(); ++iter )
  71. ////////////////////////////////////////////////////////////////////////////////////////
  72. ////////////////////////////////////////////////////////////////////////////////////////
  73. ////////////////////////////////////////////////////////////////////////////////////////
  74. /**
  75. * Disable annoying compiler warnings
  76. */
  77. #if defined(__INTEL) || defined(_MSC_VER)
  78. // Disable the warning: 'identifier' : class 'type' needs to have dll-interface to be used by clients of class 'type2'
  79. #pragma warning(disable:4251)
  80. #endif
  81. #ifdef __INTEL_COMPILER
  82. // Disable the warning: conditional expression is constant
  83. #pragma warning(disable:4127)
  84. // Disable the warning: 'identifier' : unreferenced formal parameter
  85. #pragma warning(disable:4100)
  86. // remark #383: value copied to temporary, reference to temporary used
  87. #pragma warning(disable:383)
  88. // remark #981: operands are evaluated in unspecified order
  89. // disabled -> completely pointless if the functions do not have side effects
  90. #pragma warning(disable:981)
  91. // remark #1418: external function definition with no prior declaration
  92. #pragma warning(disable:1418)
  93. // remark #1572: floating-point equality and inequality comparisons are unreliable
  94. // disabled -> everyone knows it, the parser passes this problem deliberately to the user
  95. #pragma warning(disable:1572)
  96. // remark #10121:
  97. #pragma warning(disable:10121)
  98. #endif // __INTEL_COMPILER
  99. #endif // OPEN_KARTO_MACROS_H