1*38fd1498Szrj /* ANSI and traditional C compatability macros
2*38fd1498Szrj    Copyright (C) 1991-2018 Free Software Foundation, Inc.
3*38fd1498Szrj    This file is part of the GNU C Library.
4*38fd1498Szrj 
5*38fd1498Szrj This program is free software; you can redistribute it and/or modify
6*38fd1498Szrj it under the terms of the GNU General Public License as published by
7*38fd1498Szrj the Free Software Foundation; either version 2 of the License, or
8*38fd1498Szrj (at your option) any later version.
9*38fd1498Szrj 
10*38fd1498Szrj This program is distributed in the hope that it will be useful,
11*38fd1498Szrj but WITHOUT ANY WARRANTY; without even the implied warranty of
12*38fd1498Szrj MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13*38fd1498Szrj GNU General Public License for more details.
14*38fd1498Szrj 
15*38fd1498Szrj You should have received a copy of the GNU General Public License
16*38fd1498Szrj along with this program; if not, write to the Free Software
17*38fd1498Szrj Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.  */
18*38fd1498Szrj 
19*38fd1498Szrj /* ANSI and traditional C compatibility macros
20*38fd1498Szrj 
21*38fd1498Szrj    ANSI C is assumed if __STDC__ is #defined.
22*38fd1498Szrj 
23*38fd1498Szrj    Macro		ANSI C definition	Traditional C definition
24*38fd1498Szrj    -----		---- - ----------	----------- - ----------
25*38fd1498Szrj    PTR			`void *'		`char *'
26*38fd1498Szrj    const		not defined		`'
27*38fd1498Szrj    volatile		not defined		`'
28*38fd1498Szrj    signed		not defined		`'
29*38fd1498Szrj 
30*38fd1498Szrj    For ease of writing code which uses GCC extensions but needs to be
31*38fd1498Szrj    portable to other compilers, we provide the GCC_VERSION macro that
32*38fd1498Szrj    simplifies testing __GNUC__ and __GNUC_MINOR__ together, and various
33*38fd1498Szrj    wrappers around __attribute__.  Also, __extension__ will be #defined
34*38fd1498Szrj    to nothing if it doesn't work.  See below.  */
35*38fd1498Szrj 
36*38fd1498Szrj #ifndef	_ANSIDECL_H
37*38fd1498Szrj #define _ANSIDECL_H	1
38*38fd1498Szrj 
39*38fd1498Szrj #ifdef __cplusplus
40*38fd1498Szrj extern "C" {
41*38fd1498Szrj #endif
42*38fd1498Szrj 
43*38fd1498Szrj /* Every source file includes this file,
44*38fd1498Szrj    so they will all get the switch for lint.  */
45*38fd1498Szrj /* LINTLIBRARY */
46*38fd1498Szrj 
47*38fd1498Szrj /* Using MACRO(x,y) in cpp #if conditionals does not work with some
48*38fd1498Szrj    older preprocessors.  Thus we can't define something like this:
49*38fd1498Szrj 
50*38fd1498Szrj #define HAVE_GCC_VERSION(MAJOR, MINOR) \
51*38fd1498Szrj   (__GNUC__ > (MAJOR) || (__GNUC__ == (MAJOR) && __GNUC_MINOR__ >= (MINOR)))
52*38fd1498Szrj 
53*38fd1498Szrj and then test "#if HAVE_GCC_VERSION(2,7)".
54*38fd1498Szrj 
55*38fd1498Szrj So instead we use the macro below and test it against specific values.  */
56*38fd1498Szrj 
57*38fd1498Szrj /* This macro simplifies testing whether we are using gcc, and if it
58*38fd1498Szrj    is of a particular minimum version. (Both major & minor numbers are
59*38fd1498Szrj    significant.)  This macro will evaluate to 0 if we are not using
60*38fd1498Szrj    gcc at all.  */
61*38fd1498Szrj #ifndef GCC_VERSION
62*38fd1498Szrj #define GCC_VERSION (__GNUC__ * 1000 + __GNUC_MINOR__)
63*38fd1498Szrj #endif /* GCC_VERSION */
64*38fd1498Szrj 
65*38fd1498Szrj #if defined (__STDC__) || defined(__cplusplus) || defined (_AIX) || (defined (__mips) && defined (_SYSTYPE_SVR4)) || defined(_WIN32)
66*38fd1498Szrj /* All known AIX compilers implement these things (but don't always
67*38fd1498Szrj    define __STDC__).  The RISC/OS MIPS compiler defines these things
68*38fd1498Szrj    in SVR4 mode, but does not define __STDC__.  */
69*38fd1498Szrj /* eraxxon@alumni.rice.edu: The Compaq C++ compiler, unlike many other
70*38fd1498Szrj    C++ compilers, does not define __STDC__, though it acts as if this
71*38fd1498Szrj    was so. (Verified versions: 5.7, 6.2, 6.3, 6.5) */
72*38fd1498Szrj 
73*38fd1498Szrj #define PTR		void *
74*38fd1498Szrj 
75*38fd1498Szrj #undef const
76*38fd1498Szrj #undef volatile
77*38fd1498Szrj #undef signed
78*38fd1498Szrj 
79*38fd1498Szrj /* inline requires special treatment; it's in C99, and GCC >=2.7 supports
80*38fd1498Szrj    it too, but it's not in C89.  */
81*38fd1498Szrj #undef inline
82*38fd1498Szrj #if __STDC_VERSION__ >= 199901L || defined(__cplusplus) || (defined(__SUNPRO_C) && defined(__C99FEATURES__))
83*38fd1498Szrj /* it's a keyword */
84*38fd1498Szrj #else
85*38fd1498Szrj # if GCC_VERSION >= 2007
86*38fd1498Szrj #  define inline __inline__   /* __inline__ prevents -pedantic warnings */
87*38fd1498Szrj # else
88*38fd1498Szrj #  define inline  /* nothing */
89*38fd1498Szrj # endif
90*38fd1498Szrj #endif
91*38fd1498Szrj 
92*38fd1498Szrj #else	/* Not ANSI C.  */
93*38fd1498Szrj 
94*38fd1498Szrj #define PTR		char *
95*38fd1498Szrj 
96*38fd1498Szrj /* some systems define these in header files for non-ansi mode */
97*38fd1498Szrj #undef const
98*38fd1498Szrj #undef volatile
99*38fd1498Szrj #undef signed
100*38fd1498Szrj #undef inline
101*38fd1498Szrj #define const
102*38fd1498Szrj #define volatile
103*38fd1498Szrj #define signed
104*38fd1498Szrj #define inline
105*38fd1498Szrj 
106*38fd1498Szrj #endif	/* ANSI C.  */
107*38fd1498Szrj 
108*38fd1498Szrj /* Define macros for some gcc attributes.  This permits us to use the
109*38fd1498Szrj    macros freely, and know that they will come into play for the
110*38fd1498Szrj    version of gcc in which they are supported.  */
111*38fd1498Szrj 
112*38fd1498Szrj #if (GCC_VERSION < 2007)
113*38fd1498Szrj # define __attribute__(x)
114*38fd1498Szrj #endif
115*38fd1498Szrj 
116*38fd1498Szrj /* Attribute __malloc__ on functions was valid as of gcc 2.96. */
117*38fd1498Szrj #ifndef ATTRIBUTE_MALLOC
118*38fd1498Szrj # if (GCC_VERSION >= 2096)
119*38fd1498Szrj #  define ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
120*38fd1498Szrj # else
121*38fd1498Szrj #  define ATTRIBUTE_MALLOC
122*38fd1498Szrj # endif /* GNUC >= 2.96 */
123*38fd1498Szrj #endif /* ATTRIBUTE_MALLOC */
124*38fd1498Szrj 
125*38fd1498Szrj /* Attributes on labels were valid as of gcc 2.93 and g++ 4.5.  For
126*38fd1498Szrj    g++ an attribute on a label must be followed by a semicolon.  */
127*38fd1498Szrj #ifndef ATTRIBUTE_UNUSED_LABEL
128*38fd1498Szrj # ifndef __cplusplus
129*38fd1498Szrj #  if GCC_VERSION >= 2093
130*38fd1498Szrj #   define ATTRIBUTE_UNUSED_LABEL ATTRIBUTE_UNUSED
131*38fd1498Szrj #  else
132*38fd1498Szrj #   define ATTRIBUTE_UNUSED_LABEL
133*38fd1498Szrj #  endif
134*38fd1498Szrj # else
135*38fd1498Szrj #  if GCC_VERSION >= 4005
136*38fd1498Szrj #   define ATTRIBUTE_UNUSED_LABEL ATTRIBUTE_UNUSED ;
137*38fd1498Szrj #  else
138*38fd1498Szrj #   define ATTRIBUTE_UNUSED_LABEL
139*38fd1498Szrj #  endif
140*38fd1498Szrj # endif
141*38fd1498Szrj #endif
142*38fd1498Szrj 
143*38fd1498Szrj /* Similarly to ARG_UNUSED below.  Prior to GCC 3.4, the C++ frontend
144*38fd1498Szrj    couldn't parse attributes placed after the identifier name, and now
145*38fd1498Szrj    the entire compiler is built with C++.  */
146*38fd1498Szrj #ifndef ATTRIBUTE_UNUSED
147*38fd1498Szrj #if GCC_VERSION >= 3004
148*38fd1498Szrj #  define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
149*38fd1498Szrj #else
150*38fd1498Szrj #define ATTRIBUTE_UNUSED
151*38fd1498Szrj #endif
152*38fd1498Szrj #endif /* ATTRIBUTE_UNUSED */
153*38fd1498Szrj 
154*38fd1498Szrj /* Before GCC 3.4, the C++ frontend couldn't parse attributes placed after the
155*38fd1498Szrj    identifier name.  */
156*38fd1498Szrj #if ! defined(__cplusplus) || (GCC_VERSION >= 3004)
157*38fd1498Szrj # define ARG_UNUSED(NAME) NAME ATTRIBUTE_UNUSED
158*38fd1498Szrj #else /* !__cplusplus || GNUC >= 3.4 */
159*38fd1498Szrj # define ARG_UNUSED(NAME) NAME
160*38fd1498Szrj #endif /* !__cplusplus || GNUC >= 3.4 */
161*38fd1498Szrj 
162*38fd1498Szrj #ifndef ATTRIBUTE_NORETURN
163*38fd1498Szrj #define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__))
164*38fd1498Szrj #endif /* ATTRIBUTE_NORETURN */
165*38fd1498Szrj 
166*38fd1498Szrj /* Attribute `nonnull' was valid as of gcc 3.3.  */
167*38fd1498Szrj #ifndef ATTRIBUTE_NONNULL
168*38fd1498Szrj # if (GCC_VERSION >= 3003)
169*38fd1498Szrj #  define ATTRIBUTE_NONNULL(m) __attribute__ ((__nonnull__ (m)))
170*38fd1498Szrj # else
171*38fd1498Szrj #  define ATTRIBUTE_NONNULL(m)
172*38fd1498Szrj # endif /* GNUC >= 3.3 */
173*38fd1498Szrj #endif /* ATTRIBUTE_NONNULL */
174*38fd1498Szrj 
175*38fd1498Szrj /* Attribute `returns_nonnull' was valid as of gcc 4.9.  */
176*38fd1498Szrj #ifndef ATTRIBUTE_RETURNS_NONNULL
177*38fd1498Szrj # if (GCC_VERSION >= 4009)
178*38fd1498Szrj #  define ATTRIBUTE_RETURNS_NONNULL __attribute__ ((__returns_nonnull__))
179*38fd1498Szrj # else
180*38fd1498Szrj #  define ATTRIBUTE_RETURNS_NONNULL
181*38fd1498Szrj # endif /* GNUC >= 4.9 */
182*38fd1498Szrj #endif /* ATTRIBUTE_RETURNS_NONNULL */
183*38fd1498Szrj 
184*38fd1498Szrj /* Attribute `pure' was valid as of gcc 3.0.  */
185*38fd1498Szrj #ifndef ATTRIBUTE_PURE
186*38fd1498Szrj # if (GCC_VERSION >= 3000)
187*38fd1498Szrj #  define ATTRIBUTE_PURE __attribute__ ((__pure__))
188*38fd1498Szrj # else
189*38fd1498Szrj #  define ATTRIBUTE_PURE
190*38fd1498Szrj # endif /* GNUC >= 3.0 */
191*38fd1498Szrj #endif /* ATTRIBUTE_PURE */
192*38fd1498Szrj 
193*38fd1498Szrj /* Use ATTRIBUTE_PRINTF when the format specifier must not be NULL.
194*38fd1498Szrj    This was the case for the `printf' format attribute by itself
195*38fd1498Szrj    before GCC 3.3, but as of 3.3 we need to add the `nonnull'
196*38fd1498Szrj    attribute to retain this behavior.  */
197*38fd1498Szrj #ifndef ATTRIBUTE_PRINTF
198*38fd1498Szrj #define ATTRIBUTE_PRINTF(m, n) __attribute__ ((__format__ (__printf__, m, n))) ATTRIBUTE_NONNULL(m)
199*38fd1498Szrj #define ATTRIBUTE_PRINTF_1 ATTRIBUTE_PRINTF(1, 2)
200*38fd1498Szrj #define ATTRIBUTE_PRINTF_2 ATTRIBUTE_PRINTF(2, 3)
201*38fd1498Szrj #define ATTRIBUTE_PRINTF_3 ATTRIBUTE_PRINTF(3, 4)
202*38fd1498Szrj #define ATTRIBUTE_PRINTF_4 ATTRIBUTE_PRINTF(4, 5)
203*38fd1498Szrj #define ATTRIBUTE_PRINTF_5 ATTRIBUTE_PRINTF(5, 6)
204*38fd1498Szrj #endif /* ATTRIBUTE_PRINTF */
205*38fd1498Szrj 
206*38fd1498Szrj /* Use ATTRIBUTE_FPTR_PRINTF when the format attribute is to be set on
207*38fd1498Szrj    a function pointer.  Format attributes were allowed on function
208*38fd1498Szrj    pointers as of gcc 3.1.  */
209*38fd1498Szrj #ifndef ATTRIBUTE_FPTR_PRINTF
210*38fd1498Szrj # if (GCC_VERSION >= 3001)
211*38fd1498Szrj #  define ATTRIBUTE_FPTR_PRINTF(m, n) ATTRIBUTE_PRINTF(m, n)
212*38fd1498Szrj # else
213*38fd1498Szrj #  define ATTRIBUTE_FPTR_PRINTF(m, n)
214*38fd1498Szrj # endif /* GNUC >= 3.1 */
215*38fd1498Szrj # define ATTRIBUTE_FPTR_PRINTF_1 ATTRIBUTE_FPTR_PRINTF(1, 2)
216*38fd1498Szrj # define ATTRIBUTE_FPTR_PRINTF_2 ATTRIBUTE_FPTR_PRINTF(2, 3)
217*38fd1498Szrj # define ATTRIBUTE_FPTR_PRINTF_3 ATTRIBUTE_FPTR_PRINTF(3, 4)
218*38fd1498Szrj # define ATTRIBUTE_FPTR_PRINTF_4 ATTRIBUTE_FPTR_PRINTF(4, 5)
219*38fd1498Szrj # define ATTRIBUTE_FPTR_PRINTF_5 ATTRIBUTE_FPTR_PRINTF(5, 6)
220*38fd1498Szrj #endif /* ATTRIBUTE_FPTR_PRINTF */
221*38fd1498Szrj 
222*38fd1498Szrj /* Use ATTRIBUTE_NULL_PRINTF when the format specifier may be NULL.  A
223*38fd1498Szrj    NULL format specifier was allowed as of gcc 3.3.  */
224*38fd1498Szrj #ifndef ATTRIBUTE_NULL_PRINTF
225*38fd1498Szrj # if (GCC_VERSION >= 3003)
226*38fd1498Szrj #  define ATTRIBUTE_NULL_PRINTF(m, n) __attribute__ ((__format__ (__printf__, m, n)))
227*38fd1498Szrj # else
228*38fd1498Szrj #  define ATTRIBUTE_NULL_PRINTF(m, n)
229*38fd1498Szrj # endif /* GNUC >= 3.3 */
230*38fd1498Szrj # define ATTRIBUTE_NULL_PRINTF_1 ATTRIBUTE_NULL_PRINTF(1, 2)
231*38fd1498Szrj # define ATTRIBUTE_NULL_PRINTF_2 ATTRIBUTE_NULL_PRINTF(2, 3)
232*38fd1498Szrj # define ATTRIBUTE_NULL_PRINTF_3 ATTRIBUTE_NULL_PRINTF(3, 4)
233*38fd1498Szrj # define ATTRIBUTE_NULL_PRINTF_4 ATTRIBUTE_NULL_PRINTF(4, 5)
234*38fd1498Szrj # define ATTRIBUTE_NULL_PRINTF_5 ATTRIBUTE_NULL_PRINTF(5, 6)
235*38fd1498Szrj #endif /* ATTRIBUTE_NULL_PRINTF */
236*38fd1498Szrj 
237*38fd1498Szrj /* Attribute `sentinel' was valid as of gcc 3.5.  */
238*38fd1498Szrj #ifndef ATTRIBUTE_SENTINEL
239*38fd1498Szrj # if (GCC_VERSION >= 3005)
240*38fd1498Szrj #  define ATTRIBUTE_SENTINEL __attribute__ ((__sentinel__))
241*38fd1498Szrj # else
242*38fd1498Szrj #  define ATTRIBUTE_SENTINEL
243*38fd1498Szrj # endif /* GNUC >= 3.5 */
244*38fd1498Szrj #endif /* ATTRIBUTE_SENTINEL */
245*38fd1498Szrj 
246*38fd1498Szrj 
247*38fd1498Szrj #ifndef ATTRIBUTE_ALIGNED_ALIGNOF
248*38fd1498Szrj # if (GCC_VERSION >= 3000)
249*38fd1498Szrj #  define ATTRIBUTE_ALIGNED_ALIGNOF(m) __attribute__ ((__aligned__ (__alignof__ (m))))
250*38fd1498Szrj # else
251*38fd1498Szrj #  define ATTRIBUTE_ALIGNED_ALIGNOF(m)
252*38fd1498Szrj # endif /* GNUC >= 3.0 */
253*38fd1498Szrj #endif /* ATTRIBUTE_ALIGNED_ALIGNOF */
254*38fd1498Szrj 
255*38fd1498Szrj /* Useful for structures whose layout must match some binary specification
256*38fd1498Szrj    regardless of the alignment and padding qualities of the compiler.  */
257*38fd1498Szrj #ifndef ATTRIBUTE_PACKED
258*38fd1498Szrj # define ATTRIBUTE_PACKED __attribute__ ((packed))
259*38fd1498Szrj #endif
260*38fd1498Szrj 
261*38fd1498Szrj /* Attribute `hot' and `cold' was valid as of gcc 4.3.  */
262*38fd1498Szrj #ifndef ATTRIBUTE_COLD
263*38fd1498Szrj # if (GCC_VERSION >= 4003)
264*38fd1498Szrj #  define ATTRIBUTE_COLD __attribute__ ((__cold__))
265*38fd1498Szrj # else
266*38fd1498Szrj #  define ATTRIBUTE_COLD
267*38fd1498Szrj # endif /* GNUC >= 4.3 */
268*38fd1498Szrj #endif /* ATTRIBUTE_COLD */
269*38fd1498Szrj #ifndef ATTRIBUTE_HOT
270*38fd1498Szrj # if (GCC_VERSION >= 4003)
271*38fd1498Szrj #  define ATTRIBUTE_HOT __attribute__ ((__hot__))
272*38fd1498Szrj # else
273*38fd1498Szrj #  define ATTRIBUTE_HOT
274*38fd1498Szrj # endif /* GNUC >= 4.3 */
275*38fd1498Szrj #endif /* ATTRIBUTE_HOT */
276*38fd1498Szrj 
277*38fd1498Szrj /* Attribute 'no_sanitize_undefined' was valid as of gcc 4.9.  */
278*38fd1498Szrj #ifndef ATTRIBUTE_NO_SANITIZE_UNDEFINED
279*38fd1498Szrj # if (GCC_VERSION >= 4009)
280*38fd1498Szrj #  define ATTRIBUTE_NO_SANITIZE_UNDEFINED __attribute__ ((no_sanitize_undefined))
281*38fd1498Szrj # else
282*38fd1498Szrj #  define ATTRIBUTE_NO_SANITIZE_UNDEFINED
283*38fd1498Szrj # endif /* GNUC >= 4.9 */
284*38fd1498Szrj #endif /* ATTRIBUTE_NO_SANITIZE_UNDEFINED */
285*38fd1498Szrj 
286*38fd1498Szrj /* We use __extension__ in some places to suppress -pedantic warnings
287*38fd1498Szrj    about GCC extensions.  This feature didn't work properly before
288*38fd1498Szrj    gcc 2.8.  */
289*38fd1498Szrj #if GCC_VERSION < 2008
290*38fd1498Szrj #define __extension__
291*38fd1498Szrj #endif
292*38fd1498Szrj 
293*38fd1498Szrj /* This is used to declare a const variable which should be visible
294*38fd1498Szrj    outside of the current compilation unit.  Use it as
295*38fd1498Szrj      EXPORTED_CONST int i = 1;
296*38fd1498Szrj    This is because the semantics of const are different in C and C++.
297*38fd1498Szrj    "extern const" is permitted in C but it looks strange, and gcc
298*38fd1498Szrj    warns about it when -Wc++-compat is not used.  */
299*38fd1498Szrj #ifdef __cplusplus
300*38fd1498Szrj #define EXPORTED_CONST extern const
301*38fd1498Szrj #else
302*38fd1498Szrj #define EXPORTED_CONST const
303*38fd1498Szrj #endif
304*38fd1498Szrj 
305*38fd1498Szrj /* Be conservative and only use enum bitfields with C++ or GCC.
306*38fd1498Szrj    FIXME: provide a complete autoconf test for buggy enum bitfields.  */
307*38fd1498Szrj 
308*38fd1498Szrj #ifdef __cplusplus
309*38fd1498Szrj #define ENUM_BITFIELD(TYPE) enum TYPE
310*38fd1498Szrj #elif (GCC_VERSION > 2000)
311*38fd1498Szrj #define ENUM_BITFIELD(TYPE) __extension__ enum TYPE
312*38fd1498Szrj #else
313*38fd1498Szrj #define ENUM_BITFIELD(TYPE) unsigned int
314*38fd1498Szrj #endif
315*38fd1498Szrj 
316*38fd1498Szrj #if __cpp_constexpr >= 200704
317*38fd1498Szrj #define CONSTEXPR constexpr
318*38fd1498Szrj #else
319*38fd1498Szrj #define CONSTEXPR
320*38fd1498Szrj #endif
321*38fd1498Szrj 
322*38fd1498Szrj /* C++11 adds the ability to add "override" after an implementation of a
323*38fd1498Szrj    virtual function in a subclass, to:
324*38fd1498Szrj      (A) document that this is an override of a virtual function
325*38fd1498Szrj      (B) allow the compiler to issue a warning if it isn't (e.g. a mismatch
326*38fd1498Szrj          of the type signature).
327*38fd1498Szrj 
328*38fd1498Szrj    Similarly, it allows us to add a "final" to indicate that no subclass
329*38fd1498Szrj    may subsequently override the vfunc.
330*38fd1498Szrj 
331*38fd1498Szrj    Provide OVERRIDE and FINAL as macros, allowing us to get these benefits
332*38fd1498Szrj    when compiling with C++11 support, but without requiring C++11.
333*38fd1498Szrj 
334*38fd1498Szrj    For gcc, use "-std=c++11" to enable C++11 support; gcc 6 onwards enables
335*38fd1498Szrj    this by default (actually GNU++14).  */
336*38fd1498Szrj 
337*38fd1498Szrj #if defined __cplusplus
338*38fd1498Szrj # if __cplusplus >= 201103
339*38fd1498Szrj    /* C++11 claims to be available: use it.  Final/override were only
340*38fd1498Szrj       implemented in 4.7, though.  */
341*38fd1498Szrj #  if GCC_VERSION < 4007
342*38fd1498Szrj #   define OVERRIDE
343*38fd1498Szrj #   define FINAL
344*38fd1498Szrj #  else
345*38fd1498Szrj #   define OVERRIDE override
346*38fd1498Szrj #   define FINAL final
347*38fd1498Szrj #  endif
348*38fd1498Szrj # elif GCC_VERSION >= 4007
349*38fd1498Szrj    /* G++ 4.7 supports __final in C++98.  */
350*38fd1498Szrj #  define OVERRIDE
351*38fd1498Szrj #  define FINAL __final
352*38fd1498Szrj # else
353*38fd1498Szrj    /* No C++11 support; leave the macros empty.  */
354*38fd1498Szrj #  define OVERRIDE
355*38fd1498Szrj #  define FINAL
356*38fd1498Szrj # endif
357*38fd1498Szrj #else
358*38fd1498Szrj   /* No C++11 support; leave the macros empty.  */
359*38fd1498Szrj # define OVERRIDE
360*38fd1498Szrj # define FINAL
361*38fd1498Szrj #endif
362*38fd1498Szrj 
363*38fd1498Szrj /* A macro to disable the copy constructor and assignment operator.
364*38fd1498Szrj    When building with C++11 and above, the methods are explicitly
365*38fd1498Szrj    deleted, causing a compile-time error if something tries to copy.
366*38fd1498Szrj    For C++03, this just declares the methods, causing a link-time
367*38fd1498Szrj    error if the methods end up called (assuming you don't
368*38fd1498Szrj    define them).  For C++03, for best results, place the macro
369*38fd1498Szrj    under the private: access specifier, like this,
370*38fd1498Szrj 
371*38fd1498Szrj    class name_lookup
372*38fd1498Szrj    {
373*38fd1498Szrj      private:
374*38fd1498Szrj        DISABLE_COPY_AND_ASSIGN (name_lookup);
375*38fd1498Szrj    };
376*38fd1498Szrj 
377*38fd1498Szrj    so that most attempts at copy are caught at compile-time.  */
378*38fd1498Szrj 
379*38fd1498Szrj #if __cplusplus >= 201103
380*38fd1498Szrj #define DISABLE_COPY_AND_ASSIGN(TYPE)		\
381*38fd1498Szrj   TYPE (const TYPE&) = delete;			\
382*38fd1498Szrj   void operator= (const TYPE &) = delete
383*38fd1498Szrj   #else
384*38fd1498Szrj #define DISABLE_COPY_AND_ASSIGN(TYPE)		\
385*38fd1498Szrj   TYPE (const TYPE&);				\
386*38fd1498Szrj   void operator= (const TYPE &)
387*38fd1498Szrj #endif /* __cplusplus >= 201103 */
388*38fd1498Szrj 
389*38fd1498Szrj #ifdef __cplusplus
390*38fd1498Szrj }
391*38fd1498Szrj #endif
392*38fd1498Szrj 
393*38fd1498Szrj #endif	/* ansidecl.h	*/
394