1*49678444Schristos /* This file is automatically generated. DO NOT EDIT! */ 2*49678444Schristos /* Generated from: NetBSD: mknative-gdb,v 1.12 2020/09/17 16:54:31 christos Exp */ 3*49678444Schristos /* Generated from: NetBSD: mknative.common,v 1.16 2018/04/15 15:13:37 christos Exp */ 4*49678444Schristos 5*49678444Schristos /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ 6*49678444Schristos /* A substitute for ISO C99 <ctype.h>, for platforms on which it is incomplete. 7*49678444Schristos 8*49678444Schristos Copyright (C) 2009-2020 Free Software Foundation, Inc. 9*49678444Schristos 10*49678444Schristos This program is free software; you can redistribute it and/or modify 11*49678444Schristos it under the terms of the GNU General Public License as published by 12*49678444Schristos the Free Software Foundation; either version 3, or (at your option) 13*49678444Schristos any later version. 14*49678444Schristos 15*49678444Schristos This program is distributed in the hope that it will be useful, 16*49678444Schristos but WITHOUT ANY WARRANTY; without even the implied warranty of 17*49678444Schristos MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*49678444Schristos GNU General Public License for more details. 19*49678444Schristos 20*49678444Schristos You should have received a copy of the GNU General Public License 21*49678444Schristos along with this program; if not, see <https://www.gnu.org/licenses/>. */ 22*49678444Schristos 23*49678444Schristos /* Written by Bruno Haible. */ 24*49678444Schristos 25*49678444Schristos /* 26*49678444Schristos * ISO C 99 <ctype.h> for platforms on which it is incomplete. 27*49678444Schristos * <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/ctype.h.html> 28*49678444Schristos */ 29*49678444Schristos 30*49678444Schristos #ifndef _GL_CTYPE_H 31*49678444Schristos 32*49678444Schristos #if __GNUC__ >= 3 33*49678444Schristos #pragma GCC system_header 34*49678444Schristos #endif 35*49678444Schristos 36*49678444Schristos 37*49678444Schristos /* Include the original <ctype.h>. */ 38*49678444Schristos /* The include_next requires a split double-inclusion guard. */ 39*49678444Schristos #include_next <ctype.h> 40*49678444Schristos 41*49678444Schristos #ifndef _GL_CTYPE_H 42*49678444Schristos #define _GL_CTYPE_H 43*49678444Schristos 44*49678444Schristos /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ 45*49678444Schristos /* C++ compatible function declaration macros. 46*49678444Schristos Copyright (C) 2010-2020 Free Software Foundation, Inc. 47*49678444Schristos 48*49678444Schristos This program is free software: you can redistribute it and/or modify it 49*49678444Schristos under the terms of the GNU General Public License as published 50*49678444Schristos by the Free Software Foundation; either version 3 of the License, or 51*49678444Schristos (at your option) any later version. 52*49678444Schristos 53*49678444Schristos This program is distributed in the hope that it will be useful, 54*49678444Schristos but WITHOUT ANY WARRANTY; without even the implied warranty of 55*49678444Schristos MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 56*49678444Schristos General Public License for more details. 57*49678444Schristos 58*49678444Schristos You should have received a copy of the GNU General Public License 59*49678444Schristos along with this program. If not, see <https://www.gnu.org/licenses/>. */ 60*49678444Schristos 61*49678444Schristos #ifndef _GL_CXXDEFS_H 62*49678444Schristos #define _GL_CXXDEFS_H 63*49678444Schristos 64*49678444Schristos /* Begin/end the GNULIB_NAMESPACE namespace. */ 65*49678444Schristos #if defined __cplusplus && defined GNULIB_NAMESPACE 66*49678444Schristos # define _GL_BEGIN_NAMESPACE namespace GNULIB_NAMESPACE { 67*49678444Schristos # define _GL_END_NAMESPACE } 68*49678444Schristos #else 69*49678444Schristos # define _GL_BEGIN_NAMESPACE 70*49678444Schristos # define _GL_END_NAMESPACE 71*49678444Schristos #endif 72*49678444Schristos 73*49678444Schristos /* The three most frequent use cases of these macros are: 74*49678444Schristos 75*49678444Schristos * For providing a substitute for a function that is missing on some 76*49678444Schristos platforms, but is declared and works fine on the platforms on which 77*49678444Schristos it exists: 78*49678444Schristos 79*49678444Schristos #if @GNULIB_FOO@ 80*49678444Schristos # if !@HAVE_FOO@ 81*49678444Schristos _GL_FUNCDECL_SYS (foo, ...); 82*49678444Schristos # endif 83*49678444Schristos _GL_CXXALIAS_SYS (foo, ...); 84*49678444Schristos _GL_CXXALIASWARN (foo); 85*49678444Schristos #elif defined GNULIB_POSIXCHECK 86*49678444Schristos ... 87*49678444Schristos #endif 88*49678444Schristos 89*49678444Schristos * For providing a replacement for a function that exists on all platforms, 90*49678444Schristos but is broken/insufficient and needs to be replaced on some platforms: 91*49678444Schristos 92*49678444Schristos #if @GNULIB_FOO@ 93*49678444Schristos # if @REPLACE_FOO@ 94*49678444Schristos # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 95*49678444Schristos # undef foo 96*49678444Schristos # define foo rpl_foo 97*49678444Schristos # endif 98*49678444Schristos _GL_FUNCDECL_RPL (foo, ...); 99*49678444Schristos _GL_CXXALIAS_RPL (foo, ...); 100*49678444Schristos # else 101*49678444Schristos _GL_CXXALIAS_SYS (foo, ...); 102*49678444Schristos # endif 103*49678444Schristos _GL_CXXALIASWARN (foo); 104*49678444Schristos #elif defined GNULIB_POSIXCHECK 105*49678444Schristos ... 106*49678444Schristos #endif 107*49678444Schristos 108*49678444Schristos * For providing a replacement for a function that exists on some platforms 109*49678444Schristos but is broken/insufficient and needs to be replaced on some of them and 110*49678444Schristos is additionally either missing or undeclared on some other platforms: 111*49678444Schristos 112*49678444Schristos #if @GNULIB_FOO@ 113*49678444Schristos # if @REPLACE_FOO@ 114*49678444Schristos # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 115*49678444Schristos # undef foo 116*49678444Schristos # define foo rpl_foo 117*49678444Schristos # endif 118*49678444Schristos _GL_FUNCDECL_RPL (foo, ...); 119*49678444Schristos _GL_CXXALIAS_RPL (foo, ...); 120*49678444Schristos # else 121*49678444Schristos # if !@HAVE_FOO@ or if !@HAVE_DECL_FOO@ 122*49678444Schristos _GL_FUNCDECL_SYS (foo, ...); 123*49678444Schristos # endif 124*49678444Schristos _GL_CXXALIAS_SYS (foo, ...); 125*49678444Schristos # endif 126*49678444Schristos _GL_CXXALIASWARN (foo); 127*49678444Schristos #elif defined GNULIB_POSIXCHECK 128*49678444Schristos ... 129*49678444Schristos #endif 130*49678444Schristos */ 131*49678444Schristos 132*49678444Schristos /* _GL_EXTERN_C declaration; 133*49678444Schristos performs the declaration with C linkage. */ 134*49678444Schristos #if defined __cplusplus 135*49678444Schristos # define _GL_EXTERN_C extern "C" 136*49678444Schristos #else 137*49678444Schristos # define _GL_EXTERN_C extern 138*49678444Schristos #endif 139*49678444Schristos 140*49678444Schristos /* _GL_FUNCDECL_RPL (func, rettype, parameters_and_attributes); 141*49678444Schristos declares a replacement function, named rpl_func, with the given prototype, 142*49678444Schristos consisting of return type, parameters, and attributes. 143*49678444Schristos Example: 144*49678444Schristos _GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...) 145*49678444Schristos _GL_ARG_NONNULL ((1))); 146*49678444Schristos */ 147*49678444Schristos #define _GL_FUNCDECL_RPL(func,rettype,parameters_and_attributes) \ 148*49678444Schristos _GL_FUNCDECL_RPL_1 (rpl_##func, rettype, parameters_and_attributes) 149*49678444Schristos #define _GL_FUNCDECL_RPL_1(rpl_func,rettype,parameters_and_attributes) \ 150*49678444Schristos _GL_EXTERN_C rettype rpl_func parameters_and_attributes 151*49678444Schristos 152*49678444Schristos /* _GL_FUNCDECL_SYS (func, rettype, parameters_and_attributes); 153*49678444Schristos declares the system function, named func, with the given prototype, 154*49678444Schristos consisting of return type, parameters, and attributes. 155*49678444Schristos Example: 156*49678444Schristos _GL_FUNCDECL_SYS (open, int, (const char *filename, int flags, ...) 157*49678444Schristos _GL_ARG_NONNULL ((1))); 158*49678444Schristos */ 159*49678444Schristos #define _GL_FUNCDECL_SYS(func,rettype,parameters_and_attributes) \ 160*49678444Schristos _GL_EXTERN_C rettype func parameters_and_attributes 161*49678444Schristos 162*49678444Schristos /* _GL_CXXALIAS_RPL (func, rettype, parameters); 163*49678444Schristos declares a C++ alias called GNULIB_NAMESPACE::func 164*49678444Schristos that redirects to rpl_func, if GNULIB_NAMESPACE is defined. 165*49678444Schristos Example: 166*49678444Schristos _GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...)); 167*49678444Schristos 168*49678444Schristos Wrapping rpl_func in an object with an inline conversion operator 169*49678444Schristos avoids a reference to rpl_func unless GNULIB_NAMESPACE::func is 170*49678444Schristos actually used in the program. */ 171*49678444Schristos #define _GL_CXXALIAS_RPL(func,rettype,parameters) \ 172*49678444Schristos _GL_CXXALIAS_RPL_1 (func, rpl_##func, rettype, parameters) 173*49678444Schristos #if defined __cplusplus && defined GNULIB_NAMESPACE 174*49678444Schristos # define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \ 175*49678444Schristos namespace GNULIB_NAMESPACE \ 176*49678444Schristos { \ 177*49678444Schristos static const struct _gl_ ## func ## _wrapper \ 178*49678444Schristos { \ 179*49678444Schristos typedef rettype (*type) parameters; \ 180*49678444Schristos \ 181*49678444Schristos inline operator type () const \ 182*49678444Schristos { \ 183*49678444Schristos return ::rpl_func; \ 184*49678444Schristos } \ 185*49678444Schristos } func = {}; \ 186*49678444Schristos } \ 187*49678444Schristos _GL_EXTERN_C int _gl_cxxalias_dummy 188*49678444Schristos #else 189*49678444Schristos # define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \ 190*49678444Schristos _GL_EXTERN_C int _gl_cxxalias_dummy 191*49678444Schristos #endif 192*49678444Schristos 193*49678444Schristos /* _GL_CXXALIAS_RPL_CAST_1 (func, rpl_func, rettype, parameters); 194*49678444Schristos is like _GL_CXXALIAS_RPL_1 (func, rpl_func, rettype, parameters); 195*49678444Schristos except that the C function rpl_func may have a slightly different 196*49678444Schristos declaration. A cast is used to silence the "invalid conversion" error 197*49678444Schristos that would otherwise occur. */ 198*49678444Schristos #if defined __cplusplus && defined GNULIB_NAMESPACE 199*49678444Schristos # define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \ 200*49678444Schristos namespace GNULIB_NAMESPACE \ 201*49678444Schristos { \ 202*49678444Schristos static const struct _gl_ ## func ## _wrapper \ 203*49678444Schristos { \ 204*49678444Schristos typedef rettype (*type) parameters; \ 205*49678444Schristos \ 206*49678444Schristos inline operator type () const \ 207*49678444Schristos { \ 208*49678444Schristos return reinterpret_cast<type>(::rpl_func); \ 209*49678444Schristos } \ 210*49678444Schristos } func = {}; \ 211*49678444Schristos } \ 212*49678444Schristos _GL_EXTERN_C int _gl_cxxalias_dummy 213*49678444Schristos #else 214*49678444Schristos # define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \ 215*49678444Schristos _GL_EXTERN_C int _gl_cxxalias_dummy 216*49678444Schristos #endif 217*49678444Schristos 218*49678444Schristos /* _GL_CXXALIAS_SYS (func, rettype, parameters); 219*49678444Schristos declares a C++ alias called GNULIB_NAMESPACE::func 220*49678444Schristos that redirects to the system provided function func, if GNULIB_NAMESPACE 221*49678444Schristos is defined. 222*49678444Schristos Example: 223*49678444Schristos _GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...)); 224*49678444Schristos 225*49678444Schristos Wrapping func in an object with an inline conversion operator 226*49678444Schristos avoids a reference to func unless GNULIB_NAMESPACE::func is 227*49678444Schristos actually used in the program. */ 228*49678444Schristos #if defined __cplusplus && defined GNULIB_NAMESPACE 229*49678444Schristos # define _GL_CXXALIAS_SYS(func,rettype,parameters) \ 230*49678444Schristos namespace GNULIB_NAMESPACE \ 231*49678444Schristos { \ 232*49678444Schristos static const struct _gl_ ## func ## _wrapper \ 233*49678444Schristos { \ 234*49678444Schristos typedef rettype (*type) parameters; \ 235*49678444Schristos \ 236*49678444Schristos inline operator type () const \ 237*49678444Schristos { \ 238*49678444Schristos return ::func; \ 239*49678444Schristos } \ 240*49678444Schristos } func = {}; \ 241*49678444Schristos } \ 242*49678444Schristos _GL_EXTERN_C int _gl_cxxalias_dummy 243*49678444Schristos #else 244*49678444Schristos # define _GL_CXXALIAS_SYS(func,rettype,parameters) \ 245*49678444Schristos _GL_EXTERN_C int _gl_cxxalias_dummy 246*49678444Schristos #endif 247*49678444Schristos 248*49678444Schristos /* _GL_CXXALIAS_SYS_CAST (func, rettype, parameters); 249*49678444Schristos is like _GL_CXXALIAS_SYS (func, rettype, parameters); 250*49678444Schristos except that the C function func may have a slightly different declaration. 251*49678444Schristos A cast is used to silence the "invalid conversion" error that would 252*49678444Schristos otherwise occur. */ 253*49678444Schristos #if defined __cplusplus && defined GNULIB_NAMESPACE 254*49678444Schristos # define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \ 255*49678444Schristos namespace GNULIB_NAMESPACE \ 256*49678444Schristos { \ 257*49678444Schristos static const struct _gl_ ## func ## _wrapper \ 258*49678444Schristos { \ 259*49678444Schristos typedef rettype (*type) parameters; \ 260*49678444Schristos \ 261*49678444Schristos inline operator type () const \ 262*49678444Schristos { \ 263*49678444Schristos return reinterpret_cast<type>(::func); \ 264*49678444Schristos } \ 265*49678444Schristos } func = {}; \ 266*49678444Schristos } \ 267*49678444Schristos _GL_EXTERN_C int _gl_cxxalias_dummy 268*49678444Schristos #else 269*49678444Schristos # define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \ 270*49678444Schristos _GL_EXTERN_C int _gl_cxxalias_dummy 271*49678444Schristos #endif 272*49678444Schristos 273*49678444Schristos /* _GL_CXXALIAS_SYS_CAST2 (func, rettype, parameters, rettype2, parameters2); 274*49678444Schristos is like _GL_CXXALIAS_SYS (func, rettype, parameters); 275*49678444Schristos except that the C function is picked among a set of overloaded functions, 276*49678444Schristos namely the one with rettype2 and parameters2. Two consecutive casts 277*49678444Schristos are used to silence the "cannot find a match" and "invalid conversion" 278*49678444Schristos errors that would otherwise occur. */ 279*49678444Schristos #if defined __cplusplus && defined GNULIB_NAMESPACE 280*49678444Schristos /* The outer cast must be a reinterpret_cast. 281*49678444Schristos The inner cast: When the function is defined as a set of overloaded 282*49678444Schristos functions, it works as a static_cast<>, choosing the designated variant. 283*49678444Schristos When the function is defined as a single variant, it works as a 284*49678444Schristos reinterpret_cast<>. The parenthesized cast syntax works both ways. */ 285*49678444Schristos # define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \ 286*49678444Schristos namespace GNULIB_NAMESPACE \ 287*49678444Schristos { \ 288*49678444Schristos static const struct _gl_ ## func ## _wrapper \ 289*49678444Schristos { \ 290*49678444Schristos typedef rettype (*type) parameters; \ 291*49678444Schristos \ 292*49678444Schristos inline operator type () const \ 293*49678444Schristos { \ 294*49678444Schristos return reinterpret_cast<type>((rettype2 (*) parameters2)(::func)); \ 295*49678444Schristos } \ 296*49678444Schristos } func = {}; \ 297*49678444Schristos } \ 298*49678444Schristos _GL_EXTERN_C int _gl_cxxalias_dummy 299*49678444Schristos #else 300*49678444Schristos # define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \ 301*49678444Schristos _GL_EXTERN_C int _gl_cxxalias_dummy 302*49678444Schristos #endif 303*49678444Schristos 304*49678444Schristos /* _GL_CXXALIASWARN (func); 305*49678444Schristos causes a warning to be emitted when ::func is used but not when 306*49678444Schristos GNULIB_NAMESPACE::func is used. func must be defined without overloaded 307*49678444Schristos variants. */ 308*49678444Schristos #if defined __cplusplus && defined GNULIB_NAMESPACE 309*49678444Schristos # define _GL_CXXALIASWARN(func) \ 310*49678444Schristos _GL_CXXALIASWARN_1 (func, GNULIB_NAMESPACE) 311*49678444Schristos # define _GL_CXXALIASWARN_1(func,namespace) \ 312*49678444Schristos _GL_CXXALIASWARN_2 (func, namespace) 313*49678444Schristos /* To work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>, 314*49678444Schristos we enable the warning only when not optimizing. */ 315*49678444Schristos # if !__OPTIMIZE__ 316*49678444Schristos # define _GL_CXXALIASWARN_2(func,namespace) \ 317*49678444Schristos _GL_WARN_ON_USE (func, \ 318*49678444Schristos "The symbol ::" #func " refers to the system function. " \ 319*49678444Schristos "Use " #namespace "::" #func " instead.") 320*49678444Schristos # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING 321*49678444Schristos # define _GL_CXXALIASWARN_2(func,namespace) \ 322*49678444Schristos extern __typeof__ (func) func 323*49678444Schristos # else 324*49678444Schristos # define _GL_CXXALIASWARN_2(func,namespace) \ 325*49678444Schristos _GL_EXTERN_C int _gl_cxxalias_dummy 326*49678444Schristos # endif 327*49678444Schristos #else 328*49678444Schristos # define _GL_CXXALIASWARN(func) \ 329*49678444Schristos _GL_EXTERN_C int _gl_cxxalias_dummy 330*49678444Schristos #endif 331*49678444Schristos 332*49678444Schristos /* _GL_CXXALIASWARN1 (func, rettype, parameters_and_attributes); 333*49678444Schristos causes a warning to be emitted when the given overloaded variant of ::func 334*49678444Schristos is used but not when GNULIB_NAMESPACE::func is used. */ 335*49678444Schristos #if defined __cplusplus && defined GNULIB_NAMESPACE 336*49678444Schristos # define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \ 337*49678444Schristos _GL_CXXALIASWARN1_1 (func, rettype, parameters_and_attributes, \ 338*49678444Schristos GNULIB_NAMESPACE) 339*49678444Schristos # define _GL_CXXALIASWARN1_1(func,rettype,parameters_and_attributes,namespace) \ 340*49678444Schristos _GL_CXXALIASWARN1_2 (func, rettype, parameters_and_attributes, namespace) 341*49678444Schristos /* To work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>, 342*49678444Schristos we enable the warning only when not optimizing. */ 343*49678444Schristos # if !__OPTIMIZE__ 344*49678444Schristos # define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \ 345*49678444Schristos _GL_WARN_ON_USE_CXX (func, rettype, parameters_and_attributes, \ 346*49678444Schristos "The symbol ::" #func " refers to the system function. " \ 347*49678444Schristos "Use " #namespace "::" #func " instead.") 348*49678444Schristos # else 349*49678444Schristos # define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \ 350*49678444Schristos _GL_EXTERN_C int _gl_cxxalias_dummy 351*49678444Schristos # endif 352*49678444Schristos #else 353*49678444Schristos # define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \ 354*49678444Schristos _GL_EXTERN_C int _gl_cxxalias_dummy 355*49678444Schristos #endif 356*49678444Schristos 357*49678444Schristos #endif /* _GL_CXXDEFS_H */ 358*49678444Schristos 359*49678444Schristos /* The definition of _GL_WARN_ON_USE is copied here. */ 360*49678444Schristos /* A C macro for emitting warnings if a function is used. 361*49678444Schristos Copyright (C) 2010-2020 Free Software Foundation, Inc. 362*49678444Schristos 363*49678444Schristos This program is free software: you can redistribute it and/or modify it 364*49678444Schristos under the terms of the GNU General Public License as published 365*49678444Schristos by the Free Software Foundation; either version 3 of the License, or 366*49678444Schristos (at your option) any later version. 367*49678444Schristos 368*49678444Schristos This program is distributed in the hope that it will be useful, 369*49678444Schristos but WITHOUT ANY WARRANTY; without even the implied warranty of 370*49678444Schristos MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 371*49678444Schristos General Public License for more details. 372*49678444Schristos 373*49678444Schristos You should have received a copy of the GNU General Public License 374*49678444Schristos along with this program. If not, see <https://www.gnu.org/licenses/>. */ 375*49678444Schristos 376*49678444Schristos /* _GL_WARN_ON_USE (function, "literal string") issues a declaration 377*49678444Schristos for FUNCTION which will then trigger a compiler warning containing 378*49678444Schristos the text of "literal string" anywhere that function is called, if 379*49678444Schristos supported by the compiler. If the compiler does not support this 380*49678444Schristos feature, the macro expands to an unused extern declaration. 381*49678444Schristos 382*49678444Schristos _GL_WARN_ON_USE_ATTRIBUTE ("literal string") expands to the 383*49678444Schristos attribute used in _GL_WARN_ON_USE. If the compiler does not support 384*49678444Schristos this feature, it expands to empty. 385*49678444Schristos 386*49678444Schristos These macros are useful for marking a function as a potential 387*49678444Schristos portability trap, with the intent that "literal string" include 388*49678444Schristos instructions on the replacement function that should be used 389*49678444Schristos instead. 390*49678444Schristos _GL_WARN_ON_USE is for functions with 'extern' linkage. 391*49678444Schristos _GL_WARN_ON_USE_ATTRIBUTE is for functions with 'static' or 'inline' 392*49678444Schristos linkage. 393*49678444Schristos 394*49678444Schristos However, one of the reasons that a function is a portability trap is 395*49678444Schristos if it has the wrong signature. Declaring FUNCTION with a different 396*49678444Schristos signature in C is a compilation error, so this macro must use the 397*49678444Schristos same type as any existing declaration so that programs that avoid 398*49678444Schristos the problematic FUNCTION do not fail to compile merely because they 399*49678444Schristos included a header that poisoned the function. But this implies that 400*49678444Schristos _GL_WARN_ON_USE is only safe to use if FUNCTION is known to already 401*49678444Schristos have a declaration. Use of this macro implies that there must not 402*49678444Schristos be any other macro hiding the declaration of FUNCTION; but 403*49678444Schristos undefining FUNCTION first is part of the poisoning process anyway 404*49678444Schristos (although for symbols that are provided only via a macro, the result 405*49678444Schristos is a compilation error rather than a warning containing 406*49678444Schristos "literal string"). Also note that in C++, it is only safe to use if 407*49678444Schristos FUNCTION has no overloads. 408*49678444Schristos 409*49678444Schristos For an example, it is possible to poison 'getline' by: 410*49678444Schristos - adding a call to gl_WARN_ON_USE_PREPARE([[#include <stdio.h>]], 411*49678444Schristos [getline]) in configure.ac, which potentially defines 412*49678444Schristos HAVE_RAW_DECL_GETLINE 413*49678444Schristos - adding this code to a header that wraps the system <stdio.h>: 414*49678444Schristos #undef getline 415*49678444Schristos #if HAVE_RAW_DECL_GETLINE 416*49678444Schristos _GL_WARN_ON_USE (getline, "getline is required by POSIX 2008, but" 417*49678444Schristos "not universally present; use the gnulib module getline"); 418*49678444Schristos #endif 419*49678444Schristos 420*49678444Schristos It is not possible to directly poison global variables. But it is 421*49678444Schristos possible to write a wrapper accessor function, and poison that 422*49678444Schristos (less common usage, like &environ, will cause a compilation error 423*49678444Schristos rather than issue the nice warning, but the end result of informing 424*49678444Schristos the developer about their portability problem is still achieved): 425*49678444Schristos #if HAVE_RAW_DECL_ENVIRON 426*49678444Schristos static char *** 427*49678444Schristos rpl_environ (void) { return &environ; } 428*49678444Schristos _GL_WARN_ON_USE (rpl_environ, "environ is not always properly declared"); 429*49678444Schristos # undef environ 430*49678444Schristos # define environ (*rpl_environ ()) 431*49678444Schristos #endif 432*49678444Schristos or better (avoiding contradictory use of 'static' and 'extern'): 433*49678444Schristos #if HAVE_RAW_DECL_ENVIRON 434*49678444Schristos static char *** 435*49678444Schristos _GL_WARN_ON_USE_ATTRIBUTE ("environ is not always properly declared") 436*49678444Schristos rpl_environ (void) { return &environ; } 437*49678444Schristos # undef environ 438*49678444Schristos # define environ (*rpl_environ ()) 439*49678444Schristos #endif 440*49678444Schristos */ 441*49678444Schristos #ifndef _GL_WARN_ON_USE 442*49678444Schristos 443*49678444Schristos # if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) 444*49678444Schristos /* A compiler attribute is available in gcc versions 4.3.0 and later. */ 445*49678444Schristos # define _GL_WARN_ON_USE(function, message) \ 446*49678444Schristos extern __typeof__ (function) function __attribute__ ((__warning__ (message))) 447*49678444Schristos # define _GL_WARN_ON_USE_ATTRIBUTE(message) \ 448*49678444Schristos __attribute__ ((__warning__ (message))) 449*49678444Schristos # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING 450*49678444Schristos /* Verify the existence of the function. */ 451*49678444Schristos # define _GL_WARN_ON_USE(function, message) \ 452*49678444Schristos extern __typeof__ (function) function 453*49678444Schristos # define _GL_WARN_ON_USE_ATTRIBUTE(message) 454*49678444Schristos # else /* Unsupported. */ 455*49678444Schristos # define _GL_WARN_ON_USE(function, message) \ 456*49678444Schristos _GL_WARN_EXTERN_C int _gl_warn_on_use 457*49678444Schristos # define _GL_WARN_ON_USE_ATTRIBUTE(message) 458*49678444Schristos # endif 459*49678444Schristos #endif 460*49678444Schristos 461*49678444Schristos /* _GL_WARN_ON_USE_CXX (function, rettype, parameters_and_attributes, "string") 462*49678444Schristos is like _GL_WARN_ON_USE (function, "string"), except that in C++ mode the 463*49678444Schristos function is declared with the given prototype, consisting of return type, 464*49678444Schristos parameters, and attributes. 465*49678444Schristos This variant is useful for overloaded functions in C++. _GL_WARN_ON_USE does 466*49678444Schristos not work in this case. */ 467*49678444Schristos #ifndef _GL_WARN_ON_USE_CXX 468*49678444Schristos # if !defined __cplusplus 469*49678444Schristos # define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \ 470*49678444Schristos _GL_WARN_ON_USE (function, msg) 471*49678444Schristos # else 472*49678444Schristos # if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) 473*49678444Schristos # define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \ 474*49678444Schristos extern rettype function parameters_and_attributes \ 475*49678444Schristos __attribute__ ((__warning__ (msg))) 476*49678444Schristos # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING 477*49678444Schristos /* Verify the existence of the function. */ 478*49678444Schristos # define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \ 479*49678444Schristos extern rettype function parameters_and_attributes 480*49678444Schristos # else /* Unsupported. */ 481*49678444Schristos # define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \ 482*49678444Schristos _GL_WARN_EXTERN_C int _gl_warn_on_use 483*49678444Schristos # endif 484*49678444Schristos # endif 485*49678444Schristos #endif 486*49678444Schristos 487*49678444Schristos /* _GL_WARN_EXTERN_C declaration; 488*49678444Schristos performs the declaration with C linkage. */ 489*49678444Schristos #ifndef _GL_WARN_EXTERN_C 490*49678444Schristos # if defined __cplusplus 491*49678444Schristos # define _GL_WARN_EXTERN_C extern "C" 492*49678444Schristos # else 493*49678444Schristos # define _GL_WARN_EXTERN_C extern 494*49678444Schristos # endif 495*49678444Schristos #endif 496*49678444Schristos 497*49678444Schristos /* Return non-zero if c is a blank, i.e. a space or tab character. */ 498*49678444Schristos #if 1 499*49678444Schristos # if !1 500*49678444Schristos _GL_EXTERN_C int isblank (int c); 501*49678444Schristos # endif 502*49678444Schristos #elif defined GNULIB_POSIXCHECK 503*49678444Schristos # undef isblank 504*49678444Schristos # if HAVE_RAW_DECL_ISBLANK 505*49678444Schristos _GL_WARN_ON_USE (isblank, "isblank is unportable - " 506*49678444Schristos "use gnulib module isblank for portability"); 507*49678444Schristos # endif 508*49678444Schristos #endif 509*49678444Schristos 510*49678444Schristos #endif /* _GL_CTYPE_H */ 511*49678444Schristos #endif /* _GL_CTYPE_H */ 512