co-gcc.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. // ---------------------------------------------------------------------
  2. // This file is provided by Gimpel Software (www.gimpel.com) for use with
  3. // its products PC-lint and FlexeLint.
  4. //
  5. // Redistribution and use of this file, with or without modification, is
  6. // permitted provided that any such redistribution retains this notice.
  7. // ---------------------------------------------------------------------
  8. #ifndef CO_GCC_H_
  9. #define CO_GCC_H_
  10. /*lint -save -w1 */
  11. #ifdef _lint /* Make sure no compiler comes this way */
  12. #ifdef __cplusplus
  13. extern "C" {
  14. #endif
  15. /* Standard library headers typically define the assert macro so that it
  16. expands to a complicated conditional expression that uses special
  17. funtions that Lint does not know about by default. For linting
  18. purposes, we can simplify things a bit by forcing assert() to expand to
  19. a call to a special function that has the appropriate 'assert'
  20. semantics.
  21. */
  22. //lint -function( __assert, __lint_assert )
  23. void __lint_assert( int );
  24. //lint ++d"assert(e)=__lint_assert(!!(e))"
  25. //(++d makes this definition permanently immutable for the Lint run.)
  26. //Now that we've made our own 'assert', we need to keep people from being
  27. //punished when the marco in 'assert.h' appears not to be used:
  28. //lint -efile(766,*assert.h)
  29. typedef char *__builtin_va_list;
  30. /*lint -e{171} */
  31. __builtin_va_list __lint_init_va(...);
  32. void __builtin_va_end( __builtin_va_list );
  33. /*lint
  34. ++d"__builtin_va_start(ap,parmN)=((ap)=__lint_init_va(parmN))"
  35. ++d"__builtin_va_arg(a,b)=(*( ((b) *) ( (((a) += sizeof(b)) - sizeof(b) )))"
  36. */
  37. /*
  38. The headers included below must be generated; For C++, generate
  39. with:
  40. g++ [usual build options] -E -dM t.cpp >lint_cppmac.h
  41. For C, generate with:
  42. gcc [usual build options] -E -dM t.c >lint_cmac.h
  43. ...where "t.cpp" and "t.c" are empty source files.
  44. It's important to use the same compiler options used when compiling
  45. project code because they can affect the existence and precise
  46. definitions of certain predefined macros. See gcc-readme.txt for
  47. details and a tutorial.
  48. */
  49. #if defined(__cplusplus)
  50. # include "lint_cppmac.h" // DO NOT COMMENT THIS OUT. DO NOT SUPPRESS ERROR 322. (If you see an error here, your Lint configuration is broken; check -i options and ensure that you have generated lint_cppmac.h as documented in gcc-readme.txt. Otherwise Gimpel Software cannot support your configuration.)
  51. #else
  52. # include "lint_cmac.h" // DO NOT COMMENT THIS OUT. DO NOT SUPPRESS ERROR 322. (If you see an error here, your Lint configuration is broken; check -i options and ensure that you have generated lint_cmac.h as documented in gcc-readme.txt. Otherwise Gimpel Software cannot support your configuration.)
  53. #endif
  54. /* If the macro set given by the generated macro files must be adjusted in
  55. order for Lint to cope, then you can make those adjustments here.
  56. */
  57. #define LINT_CO_GCC_H_GCC_VERSION ( __GNUC__ * 10000 + \
  58. __GNUC_MINOR__ * 100 + \
  59. __GNUC_PATCHLEVEL__ )
  60. /* The following is a workaround for versions of GCC with bug 25717, in
  61. which the preprocessor does not dump a #define directive for __STDC__
  62. when -dM is given:
  63. http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25717
  64. We know the unconditional definition of __STDC__ was introduced no
  65. later than version 3.0; the preprocessor bug was fixed no later than
  66. version 4.1.0.
  67. */
  68. #if ( LINT_CO_GCC_H_GCC_VERSION >= 30000 && \
  69. LINT_CO_GCC_H_GCC_VERSION < 40100 )
  70. # define __STDC__ 1
  71. #endif
  72. #if !__cplusplus && !__STRICT_ANSI__ && __STDC_VERSION__ < 199901L
  73. /* apparently, the code is compiled with -std=gnu89 (as opposed to -std=c89),
  74. so: */
  75. /*lint -rw_asgn(inline,__inline) */
  76. #endif
  77. #if LINT_CO_GCC_H_GCC_VERSION >= 40300
  78. # define __COUNTER__ __lint__COUNTER__
  79. //lint +rw( *type_traits ) // Enable type traits support
  80. #endif
  81. #ifdef __cplusplus
  82. } /* extern "C" */
  83. #endif
  84. #if _lint >= 909 // For 9.00i and later:
  85. //// __attribute__ is GCC's __attribute__:
  86. //
  87. //lint -rw_asgn(__attribute__,__gcc_attribute__)
  88. //lint -rw_asgn(__attribute, __gcc_attribute__)
  89. //
  90. //// Prevent "__attribute__" from being defined as a macro:
  91. //
  92. //lint --u"__attribute__"
  93. //lint --u"__attribute"
  94. //
  95. //// Because an attribute-specifier is a form of
  96. //// declaration-modifier, and because it can appear at the
  97. //// beginning of a decl-specifier-seq, we must enable "Early
  98. //// Modifiers":
  99. //
  100. //lint +fem
  101. #else // for 9.00h and earlier:
  102. //lint -d__attribute__()=
  103. //lint -d__attribute()=
  104. #endif
  105. #endif /* _lint */
  106. /*lint -restore */
  107. #endif /* CO_GCC_H_ */