comparison src/compiler.h @ 1748:19b0fcab3f47

[xemacs-hg @ 2003-10-14 17:01:09 by james] Unbreak non-gcc builds. Mea culpa.
author james
date Tue, 14 Oct 2003 17:01:15 +0000
parents e4f996d69637
children 61855263cb07
comparison
equal deleted inserted replaced
1747:8fcb82013b26 1748:19b0fcab3f47
37 /* Define min() and max(). (Some compilers put them in strange places that 37 /* Define min() and max(). (Some compilers put them in strange places that
38 won't be referenced by include files used by XEmacs, such as 'macros.h' 38 won't be referenced by include files used by XEmacs, such as 'macros.h'
39 under Solaris.) */ 39 under Solaris.) */
40 40
41 #ifndef min 41 #ifndef min
42 #define min(a,b) (((a) <= (b)) ? (a) : (b)) 42 # define min(a,b) (((a) <= (b)) ? (a) : (b))
43 #endif 43 #endif
44 #ifndef max 44 #ifndef max
45 #define max(a,b) (((a) > (b)) ? (a) : (b)) 45 # define max(a,b) (((a) > (b)) ? (a) : (b))
46 #endif 46 #endif
47 47
48 /* Regular C complains about possible clobbering of local vars NOT declared 48 /* Regular C complains about possible clobbering of local vars NOT declared
49 as volatile if there's a longjmp() in a function. C++ complains if such 49 as volatile if there's a longjmp() in a function. C++ complains if such
50 vars ARE volatile; or more correctly, sans volatile no problem even when 50 vars ARE volatile; or more correctly, sans volatile no problem even when
57 /src/xemacs/lilfix/src/lisp-union.h:32: candidates are: 57 /src/xemacs/lilfix/src/lisp-union.h:32: candidates are:
58 Lisp_Object::Lisp_Object(const Lisp_Object&) 58 Lisp_Object::Lisp_Object(const Lisp_Object&)
59 */ 59 */
60 60
61 #ifdef __cplusplus 61 #ifdef __cplusplus
62 #define VOLATILE_IF_NOT_CPP 62 # define VOLATILE_IF_NOT_CPP
63 #else 63 #else
64 #define VOLATILE_IF_NOT_CPP volatile 64 # define VOLATILE_IF_NOT_CPP volatile
65 #endif 65 #endif
66 66
67 /* Avoid indentation problems when XEmacs sees the curly braces */ 67 /* Avoid indentation problems when XEmacs sees the curly braces */
68 #ifndef BEGIN_C_DECLS 68 #ifndef BEGIN_C_DECLS
69 # ifdef __cplusplus 69 # ifdef __cplusplus
73 # define BEGIN_C_DECLS 73 # define BEGIN_C_DECLS
74 # define END_C_DECLS 74 # define END_C_DECLS
75 # endif 75 # endif
76 #endif 76 #endif
77 77
78 /* Macro simplification for non-GNU compilers and older gccs that did not 78 /* Guard against older gccs that did not define all of these symbols */
79 define all of these symbols */ 79 #ifdef __GNUC__
80 #ifndef __GNUC__ 80 # ifndef __GNUC_MINOR__
81 #define __GNUC__ 0 81 # define __GNUC_MINOR__ 0
82 #endif 82 # endif
83 #ifndef __GNUC_MINOR__ 83 # ifndef __GNUC_PATCHLEVEL__
84 #define __GNUC_MINOR__ 0 84 # define __GNUC_PATCHLEVEL__ 0
85 #endif 85 # endif
86 #ifndef __GNUC_PATCHLEVEL__ 86 #endif /* __GNUC__ */
87 #define __GNUC_PATCHLEVEL__ 0 87
88 #endif 88 /* Simplify testing for specific GCC versions. For non-GNU compilers,
89 89 GCC_VERSION evaluates to zero. */
90 /* Simplify testing for specific GCC versions. This also works for non-GCC
91 compilers, where GCC_VERSION is zero. */
92 #ifndef NEED_GCC 90 #ifndef NEED_GCC
93 #define NEED_GCC(major,minor,patch) (major * 1000000 + minor * 1000 + patch) 91 # define NEED_GCC(major,minor,patch) (major * 1000000 + minor * 1000 + patch)
94 #endif /* NEED_GCC */ 92 #endif /* NEED_GCC */
95 #ifndef GCC_VERSION 93 #ifndef GCC_VERSION
96 #define GCC_VERSION NEED_GCC (__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__) 94 # ifdef __GNUC__
95 # define GCC_VERSION NEED_GCC (__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__)
96 # else
97 # define GCC_VERSION 0
98 # endif /* __GNUC__ */
97 #endif /* GCC_VERSION */ 99 #endif /* GCC_VERSION */
98 100
99 /* GCC < 2.6.0 could only declare one attribute per function. In that case, 101 /* GCC < 2.6.0 could only declare one attribute per function. In that case,
100 we define DOESNT_RETURN in preference to PRINTF_ARGS, which is only used 102 we define DOESNT_RETURN in preference to PRINTF_ARGS, which is only used
101 for checking args against the string spec. */ 103 for checking args against the string spec. */
130 132
131 /* Another try to fix SunPro C compiler warnings */ 133 /* Another try to fix SunPro C compiler warnings */
132 /* "end-of-loop code not reached" */ 134 /* "end-of-loop code not reached" */
133 /* "statement not reached */ 135 /* "statement not reached */
134 #if defined __SUNPRO_C || defined __USLC__ 136 #if defined __SUNPRO_C || defined __USLC__
135 #define RETURN_SANS_WARNINGS if (1) return 137 # define RETURN_SANS_WARNINGS if (1) return
136 #define RETURN_NOT_REACHED(value) DO_NOTHING 138 # define RETURN_NOT_REACHED(value) DO_NOTHING
137 #endif 139 #endif
138 140
139 /* More ways to shut up compiler. This works in Fcommand_loop_1(), 141 /* More ways to shut up compiler. This works in Fcommand_loop_1(),
140 where there's an infinite loop in a function returning a Lisp object. 142 where there's an infinite loop in a function returning a Lisp object.
141 */ 143 */
142 #if defined (_MSC_VER) || defined (__SUNPRO_C) || defined (__SUNPRO_CC) || \ 144 #if defined (_MSC_VER) || defined (__SUNPRO_C) || defined (__SUNPRO_CC) || \
143 (defined (DEC_ALPHA) && defined (OSF1)) 145 (defined (DEC_ALPHA) && defined (OSF1))
144 #define DO_NOTHING_DISABLING_NO_RETURN_WARNINGS if (0) return Qnil 146 # define DO_NOTHING_DISABLING_NO_RETURN_WARNINGS if (0) return Qnil
145 #else 147 #else
146 #define DO_NOTHING_DISABLING_NO_RETURN_WARNINGS DO_NOTHING 148 # define DO_NOTHING_DISABLING_NO_RETURN_WARNINGS DO_NOTHING
147 #endif 149 #endif
148 150
149 #ifndef RETURN_NOT_REACHED 151 #ifndef RETURN_NOT_REACHED
150 #define RETURN_NOT_REACHED(value) return (value) 152 # define RETURN_NOT_REACHED(value) return (value)
151 #endif 153 #endif
152 154
153 #ifndef RETURN_SANS_WARNINGS 155 #ifndef RETURN_SANS_WARNINGS
154 #define RETURN_SANS_WARNINGS return 156 # define RETURN_SANS_WARNINGS return
155 #endif 157 #endif
156 158
157 #ifndef DO_NOTHING 159 #ifndef DO_NOTHING
158 #define DO_NOTHING do {} while (0) 160 # define DO_NOTHING do {} while (0)
159 #endif 161 #endif
160 162
161 #ifndef DECLARE_NOTHING 163 #ifndef DECLARE_NOTHING
162 #define DECLARE_NOTHING struct nosuchstruct 164 # define DECLARE_NOTHING struct nosuchstruct
163 #endif 165 #endif
164 166
165 #ifndef ATTRIBUTE_MALLOC 167 #ifndef ATTRIBUTE_MALLOC
166 # if (GCC_VERSION >= NEED_GCC (2, 96, 0)) 168 # if (GCC_VERSION >= NEED_GCC (2, 96, 0))
167 # define ATTRIBUTE_MALLOC __attribute__ ((__malloc__)) 169 # define ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
196 # define UNUSED_ARG 198 # define UNUSED_ARG
197 # endif 199 # endif
198 #endif /* ATTRIBUTE_UNUSED */ 200 #endif /* ATTRIBUTE_UNUSED */
199 201
200 #ifdef DEBUG_XEMACS 202 #ifdef DEBUG_XEMACS
201 #define REGISTER 203 # define REGISTER
202 #define register 204 # define register
203 #else 205 #else
204 #define REGISTER register 206 # define REGISTER register
205 #endif 207 #endif
206 208
207 #if defined(HAVE_MS_WINDOWS) && defined(HAVE_SHLIB) 209 #if defined(HAVE_MS_WINDOWS) && defined(HAVE_SHLIB)
208 # ifdef EMACS_MODULE 210 # ifdef EMACS_MODULE
209 # define MODULE_API __declspec(dllimport) 211 # define MODULE_API __declspec(dllimport)