1 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */ 2 /* Substitute for and wrapper around <langinfo.h>. 3 Copyright (C) 2009-2020 Free Software Foundation, Inc. 4 5 This program is free software; you can redistribute it and/or modify 6 it under the terms of the GNU General Public License as published by 7 the Free Software Foundation; either version 3, or (at your option) 8 any later version. 9 10 This program is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 GNU General Public License for more details. 14 15 You should have received a copy of the GNU General Public License 16 along with this program; if not, see <https://www.gnu.org/licenses/>. */ 17 18 /* 19 * POSIX <langinfo.h> for platforms that lack it or have an incomplete one. 20 * <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/langinfo.h.html> 21 */ 22 23 #ifndef _GL_LANGINFO_H 24 25 #if __GNUC__ >= 3 26 #pragma GCC system_header 27 #endif 28 29 30 /* The include_next requires a split double-inclusion guard. */ 31 #if 1 32 # include_next <langinfo.h> 33 #endif 34 35 #ifndef _GL_LANGINFO_H 36 #define _GL_LANGINFO_H 37 38 39 #if !1 40 41 /* A platform that lacks <langinfo.h>. */ 42 43 /* Assume that it also lacks <nl_types.h> and the nl_item type. */ 44 # if !GNULIB_defined_nl_item 45 typedef int nl_item; 46 # define GNULIB_defined_nl_item 1 47 # endif 48 49 /* nl_langinfo items of the LC_CTYPE category */ 50 # define CODESET 10000 51 /* nl_langinfo items of the LC_NUMERIC category */ 52 # define RADIXCHAR 10001 53 # define DECIMAL_POINT RADIXCHAR 54 # define THOUSEP 10002 55 # define THOUSANDS_SEP THOUSEP 56 # define GROUPING 10114 57 /* nl_langinfo items of the LC_TIME category */ 58 # define D_T_FMT 10003 59 # define D_FMT 10004 60 # define T_FMT 10005 61 # define T_FMT_AMPM 10006 62 # define AM_STR 10007 63 # define PM_STR 10008 64 # define DAY_1 10009 65 # define DAY_2 (DAY_1 + 1) 66 # define DAY_3 (DAY_1 + 2) 67 # define DAY_4 (DAY_1 + 3) 68 # define DAY_5 (DAY_1 + 4) 69 # define DAY_6 (DAY_1 + 5) 70 # define DAY_7 (DAY_1 + 6) 71 # define ABDAY_1 10016 72 # define ABDAY_2 (ABDAY_1 + 1) 73 # define ABDAY_3 (ABDAY_1 + 2) 74 # define ABDAY_4 (ABDAY_1 + 3) 75 # define ABDAY_5 (ABDAY_1 + 4) 76 # define ABDAY_6 (ABDAY_1 + 5) 77 # define ABDAY_7 (ABDAY_1 + 6) 78 # define MON_1 10023 79 # define MON_2 (MON_1 + 1) 80 # define MON_3 (MON_1 + 2) 81 # define MON_4 (MON_1 + 3) 82 # define MON_5 (MON_1 + 4) 83 # define MON_6 (MON_1 + 5) 84 # define MON_7 (MON_1 + 6) 85 # define MON_8 (MON_1 + 7) 86 # define MON_9 (MON_1 + 8) 87 # define MON_10 (MON_1 + 9) 88 # define MON_11 (MON_1 + 10) 89 # define MON_12 (MON_1 + 11) 90 # define ALTMON_1 10200 91 # define ALTMON_2 (ALTMON_1 + 1) 92 # define ALTMON_3 (ALTMON_1 + 2) 93 # define ALTMON_4 (ALTMON_1 + 3) 94 # define ALTMON_5 (ALTMON_1 + 4) 95 # define ALTMON_6 (ALTMON_1 + 5) 96 # define ALTMON_7 (ALTMON_1 + 6) 97 # define ALTMON_8 (ALTMON_1 + 7) 98 # define ALTMON_9 (ALTMON_1 + 8) 99 # define ALTMON_10 (ALTMON_1 + 9) 100 # define ALTMON_11 (ALTMON_1 + 10) 101 # define ALTMON_12 (ALTMON_1 + 11) 102 # define ABMON_1 10035 103 # define ABMON_2 (ABMON_1 + 1) 104 # define ABMON_3 (ABMON_1 + 2) 105 # define ABMON_4 (ABMON_1 + 3) 106 # define ABMON_5 (ABMON_1 + 4) 107 # define ABMON_6 (ABMON_1 + 5) 108 # define ABMON_7 (ABMON_1 + 6) 109 # define ABMON_8 (ABMON_1 + 7) 110 # define ABMON_9 (ABMON_1 + 8) 111 # define ABMON_10 (ABMON_1 + 9) 112 # define ABMON_11 (ABMON_1 + 10) 113 # define ABMON_12 (ABMON_1 + 11) 114 # define ERA 10047 115 # define ERA_D_FMT 10048 116 # define ERA_D_T_FMT 10049 117 # define ERA_T_FMT 10050 118 # define ALT_DIGITS 10051 119 /* nl_langinfo items of the LC_MONETARY category */ 120 # define CRNCYSTR 10052 121 # define CURRENCY_SYMBOL CRNCYSTR 122 # define INT_CURR_SYMBOL 10100 123 # define MON_DECIMAL_POINT 10101 124 # define MON_THOUSANDS_SEP 10102 125 # define MON_GROUPING 10103 126 # define POSITIVE_SIGN 10104 127 # define NEGATIVE_SIGN 10105 128 # define FRAC_DIGITS 10106 129 # define INT_FRAC_DIGITS 10107 130 # define P_CS_PRECEDES 10108 131 # define N_CS_PRECEDES 10109 132 # define P_SEP_BY_SPACE 10110 133 # define N_SEP_BY_SPACE 10111 134 # define P_SIGN_POSN 10112 135 # define N_SIGN_POSN 10113 136 /* nl_langinfo items of the LC_MESSAGES category */ 137 # define YESEXPR 10053 138 # define NOEXPR 10054 139 140 #else 141 142 /* A platform that has <langinfo.h>. */ 143 144 # if !1 145 # define CODESET 10000 146 # define GNULIB_defined_CODESET 1 147 # endif 148 149 # if !1 150 # define T_FMT_AMPM 10006 151 # define GNULIB_defined_T_FMT_AMPM 1 152 # endif 153 154 # if !1 155 # define ALTMON_1 10200 156 # define ALTMON_2 (ALTMON_1 + 1) 157 # define ALTMON_3 (ALTMON_1 + 2) 158 # define ALTMON_4 (ALTMON_1 + 3) 159 # define ALTMON_5 (ALTMON_1 + 4) 160 # define ALTMON_6 (ALTMON_1 + 5) 161 # define ALTMON_7 (ALTMON_1 + 6) 162 # define ALTMON_8 (ALTMON_1 + 7) 163 # define ALTMON_9 (ALTMON_1 + 8) 164 # define ALTMON_10 (ALTMON_1 + 9) 165 # define ALTMON_11 (ALTMON_1 + 10) 166 # define ALTMON_12 (ALTMON_1 + 11) 167 # define GNULIB_defined_ALTMON 1 168 # endif 169 170 # if !1 171 # define ERA 10047 172 # define ERA_D_FMT 10048 173 # define ERA_D_T_FMT 10049 174 # define ERA_T_FMT 10050 175 # define ALT_DIGITS 10051 176 # define GNULIB_defined_ERA 1 177 # endif 178 179 # if !1 180 # define YESEXPR 10053 181 # define NOEXPR 10054 182 # define GNULIB_defined_YESEXPR 1 183 # endif 184 185 #endif 186 187 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ 188 /* C++ compatible function declaration macros. 189 Copyright (C) 2010-2020 Free Software Foundation, Inc. 190 191 This program is free software: you can redistribute it and/or modify it 192 under the terms of the GNU General Public License as published 193 by the Free Software Foundation; either version 3 of the License, or 194 (at your option) any later version. 195 196 This program is distributed in the hope that it will be useful, 197 but WITHOUT ANY WARRANTY; without even the implied warranty of 198 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 199 General Public License for more details. 200 201 You should have received a copy of the GNU General Public License 202 along with this program. If not, see <https://www.gnu.org/licenses/>. */ 203 204 #ifndef _GL_CXXDEFS_H 205 #define _GL_CXXDEFS_H 206 207 /* Begin/end the GNULIB_NAMESPACE namespace. */ 208 #if defined __cplusplus && defined GNULIB_NAMESPACE 209 # define _GL_BEGIN_NAMESPACE namespace GNULIB_NAMESPACE { 210 # define _GL_END_NAMESPACE } 211 #else 212 # define _GL_BEGIN_NAMESPACE 213 # define _GL_END_NAMESPACE 214 #endif 215 216 /* The three most frequent use cases of these macros are: 217 218 * For providing a substitute for a function that is missing on some 219 platforms, but is declared and works fine on the platforms on which 220 it exists: 221 222 #if @GNULIB_FOO@ 223 # if !@HAVE_FOO@ 224 _GL_FUNCDECL_SYS (foo, ...); 225 # endif 226 _GL_CXXALIAS_SYS (foo, ...); 227 _GL_CXXALIASWARN (foo); 228 #elif defined GNULIB_POSIXCHECK 229 ... 230 #endif 231 232 * For providing a replacement for a function that exists on all platforms, 233 but is broken/insufficient and needs to be replaced on some platforms: 234 235 #if @GNULIB_FOO@ 236 # if @REPLACE_FOO@ 237 # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 238 # undef foo 239 # define foo rpl_foo 240 # endif 241 _GL_FUNCDECL_RPL (foo, ...); 242 _GL_CXXALIAS_RPL (foo, ...); 243 # else 244 _GL_CXXALIAS_SYS (foo, ...); 245 # endif 246 _GL_CXXALIASWARN (foo); 247 #elif defined GNULIB_POSIXCHECK 248 ... 249 #endif 250 251 * For providing a replacement for a function that exists on some platforms 252 but is broken/insufficient and needs to be replaced on some of them and 253 is additionally either missing or undeclared on some other platforms: 254 255 #if @GNULIB_FOO@ 256 # if @REPLACE_FOO@ 257 # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 258 # undef foo 259 # define foo rpl_foo 260 # endif 261 _GL_FUNCDECL_RPL (foo, ...); 262 _GL_CXXALIAS_RPL (foo, ...); 263 # else 264 # if !@HAVE_FOO@ or if !@HAVE_DECL_FOO@ 265 _GL_FUNCDECL_SYS (foo, ...); 266 # endif 267 _GL_CXXALIAS_SYS (foo, ...); 268 # endif 269 _GL_CXXALIASWARN (foo); 270 #elif defined GNULIB_POSIXCHECK 271 ... 272 #endif 273 */ 274 275 /* _GL_EXTERN_C declaration; 276 performs the declaration with C linkage. */ 277 #if defined __cplusplus 278 # define _GL_EXTERN_C extern "C" 279 #else 280 # define _GL_EXTERN_C extern 281 #endif 282 283 /* _GL_FUNCDECL_RPL (func, rettype, parameters_and_attributes); 284 declares a replacement function, named rpl_func, with the given prototype, 285 consisting of return type, parameters, and attributes. 286 Example: 287 _GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...) 288 _GL_ARG_NONNULL ((1))); 289 */ 290 #define _GL_FUNCDECL_RPL(func,rettype,parameters_and_attributes) \ 291 _GL_FUNCDECL_RPL_1 (rpl_##func, rettype, parameters_and_attributes) 292 #define _GL_FUNCDECL_RPL_1(rpl_func,rettype,parameters_and_attributes) \ 293 _GL_EXTERN_C rettype rpl_func parameters_and_attributes 294 295 /* _GL_FUNCDECL_SYS (func, rettype, parameters_and_attributes); 296 declares the system function, named func, with the given prototype, 297 consisting of return type, parameters, and attributes. 298 Example: 299 _GL_FUNCDECL_SYS (open, int, (const char *filename, int flags, ...) 300 _GL_ARG_NONNULL ((1))); 301 */ 302 #define _GL_FUNCDECL_SYS(func,rettype,parameters_and_attributes) \ 303 _GL_EXTERN_C rettype func parameters_and_attributes 304 305 /* _GL_CXXALIAS_RPL (func, rettype, parameters); 306 declares a C++ alias called GNULIB_NAMESPACE::func 307 that redirects to rpl_func, if GNULIB_NAMESPACE is defined. 308 Example: 309 _GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...)); 310 311 Wrapping rpl_func in an object with an inline conversion operator 312 avoids a reference to rpl_func unless GNULIB_NAMESPACE::func is 313 actually used in the program. */ 314 #define _GL_CXXALIAS_RPL(func,rettype,parameters) \ 315 _GL_CXXALIAS_RPL_1 (func, rpl_##func, rettype, parameters) 316 #if defined __cplusplus && defined GNULIB_NAMESPACE 317 # define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \ 318 namespace GNULIB_NAMESPACE \ 319 { \ 320 static const struct _gl_ ## func ## _wrapper \ 321 { \ 322 typedef rettype (*type) parameters; \ 323 \ 324 inline operator type () const \ 325 { \ 326 return ::rpl_func; \ 327 } \ 328 } func = {}; \ 329 } \ 330 _GL_EXTERN_C int _gl_cxxalias_dummy 331 #else 332 # define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \ 333 _GL_EXTERN_C int _gl_cxxalias_dummy 334 #endif 335 336 /* _GL_CXXALIAS_RPL_CAST_1 (func, rpl_func, rettype, parameters); 337 is like _GL_CXXALIAS_RPL_1 (func, rpl_func, rettype, parameters); 338 except that the C function rpl_func may have a slightly different 339 declaration. A cast is used to silence the "invalid conversion" error 340 that would otherwise occur. */ 341 #if defined __cplusplus && defined GNULIB_NAMESPACE 342 # define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \ 343 namespace GNULIB_NAMESPACE \ 344 { \ 345 static const struct _gl_ ## func ## _wrapper \ 346 { \ 347 typedef rettype (*type) parameters; \ 348 \ 349 inline operator type () const \ 350 { \ 351 return reinterpret_cast<type>(::rpl_func); \ 352 } \ 353 } func = {}; \ 354 } \ 355 _GL_EXTERN_C int _gl_cxxalias_dummy 356 #else 357 # define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \ 358 _GL_EXTERN_C int _gl_cxxalias_dummy 359 #endif 360 361 /* _GL_CXXALIAS_SYS (func, rettype, parameters); 362 declares a C++ alias called GNULIB_NAMESPACE::func 363 that redirects to the system provided function func, if GNULIB_NAMESPACE 364 is defined. 365 Example: 366 _GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...)); 367 368 Wrapping func in an object with an inline conversion operator 369 avoids a reference to func unless GNULIB_NAMESPACE::func is 370 actually used in the program. */ 371 #if defined __cplusplus && defined GNULIB_NAMESPACE 372 # define _GL_CXXALIAS_SYS(func,rettype,parameters) \ 373 namespace GNULIB_NAMESPACE \ 374 { \ 375 static const struct _gl_ ## func ## _wrapper \ 376 { \ 377 typedef rettype (*type) parameters; \ 378 \ 379 inline operator type () const \ 380 { \ 381 return ::func; \ 382 } \ 383 } func = {}; \ 384 } \ 385 _GL_EXTERN_C int _gl_cxxalias_dummy 386 #else 387 # define _GL_CXXALIAS_SYS(func,rettype,parameters) \ 388 _GL_EXTERN_C int _gl_cxxalias_dummy 389 #endif 390 391 /* _GL_CXXALIAS_SYS_CAST (func, rettype, parameters); 392 is like _GL_CXXALIAS_SYS (func, rettype, parameters); 393 except that the C function func may have a slightly different declaration. 394 A cast is used to silence the "invalid conversion" error that would 395 otherwise occur. */ 396 #if defined __cplusplus && defined GNULIB_NAMESPACE 397 # define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \ 398 namespace GNULIB_NAMESPACE \ 399 { \ 400 static const struct _gl_ ## func ## _wrapper \ 401 { \ 402 typedef rettype (*type) parameters; \ 403 \ 404 inline operator type () const \ 405 { \ 406 return reinterpret_cast<type>(::func); \ 407 } \ 408 } func = {}; \ 409 } \ 410 _GL_EXTERN_C int _gl_cxxalias_dummy 411 #else 412 # define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \ 413 _GL_EXTERN_C int _gl_cxxalias_dummy 414 #endif 415 416 /* _GL_CXXALIAS_SYS_CAST2 (func, rettype, parameters, rettype2, parameters2); 417 is like _GL_CXXALIAS_SYS (func, rettype, parameters); 418 except that the C function is picked among a set of overloaded functions, 419 namely the one with rettype2 and parameters2. Two consecutive casts 420 are used to silence the "cannot find a match" and "invalid conversion" 421 errors that would otherwise occur. */ 422 #if defined __cplusplus && defined GNULIB_NAMESPACE 423 /* The outer cast must be a reinterpret_cast. 424 The inner cast: When the function is defined as a set of overloaded 425 functions, it works as a static_cast<>, choosing the designated variant. 426 When the function is defined as a single variant, it works as a 427 reinterpret_cast<>. The parenthesized cast syntax works both ways. */ 428 # define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \ 429 namespace GNULIB_NAMESPACE \ 430 { \ 431 static const struct _gl_ ## func ## _wrapper \ 432 { \ 433 typedef rettype (*type) parameters; \ 434 \ 435 inline operator type () const \ 436 { \ 437 return reinterpret_cast<type>((rettype2 (*) parameters2)(::func)); \ 438 } \ 439 } func = {}; \ 440 } \ 441 _GL_EXTERN_C int _gl_cxxalias_dummy 442 #else 443 # define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \ 444 _GL_EXTERN_C int _gl_cxxalias_dummy 445 #endif 446 447 /* _GL_CXXALIASWARN (func); 448 causes a warning to be emitted when ::func is used but not when 449 GNULIB_NAMESPACE::func is used. func must be defined without overloaded 450 variants. */ 451 #if defined __cplusplus && defined GNULIB_NAMESPACE 452 # define _GL_CXXALIASWARN(func) \ 453 _GL_CXXALIASWARN_1 (func, GNULIB_NAMESPACE) 454 # define _GL_CXXALIASWARN_1(func,namespace) \ 455 _GL_CXXALIASWARN_2 (func, namespace) 456 /* To work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>, 457 we enable the warning only when not optimizing. */ 458 # if !__OPTIMIZE__ 459 # define _GL_CXXALIASWARN_2(func,namespace) \ 460 _GL_WARN_ON_USE (func, \ 461 "The symbol ::" #func " refers to the system function. " \ 462 "Use " #namespace "::" #func " instead.") 463 # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING 464 # define _GL_CXXALIASWARN_2(func,namespace) \ 465 extern __typeof__ (func) func 466 # else 467 # define _GL_CXXALIASWARN_2(func,namespace) \ 468 _GL_EXTERN_C int _gl_cxxalias_dummy 469 # endif 470 #else 471 # define _GL_CXXALIASWARN(func) \ 472 _GL_EXTERN_C int _gl_cxxalias_dummy 473 #endif 474 475 /* _GL_CXXALIASWARN1 (func, rettype, parameters_and_attributes); 476 causes a warning to be emitted when the given overloaded variant of ::func 477 is used but not when GNULIB_NAMESPACE::func is used. */ 478 #if defined __cplusplus && defined GNULIB_NAMESPACE 479 # define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \ 480 _GL_CXXALIASWARN1_1 (func, rettype, parameters_and_attributes, \ 481 GNULIB_NAMESPACE) 482 # define _GL_CXXALIASWARN1_1(func,rettype,parameters_and_attributes,namespace) \ 483 _GL_CXXALIASWARN1_2 (func, rettype, parameters_and_attributes, namespace) 484 /* To work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>, 485 we enable the warning only when not optimizing. */ 486 # if !__OPTIMIZE__ 487 # define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \ 488 _GL_WARN_ON_USE_CXX (func, rettype, parameters_and_attributes, \ 489 "The symbol ::" #func " refers to the system function. " \ 490 "Use " #namespace "::" #func " instead.") 491 # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING 492 # define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \ 493 extern __typeof__ (func) func 494 # else 495 # define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \ 496 _GL_EXTERN_C int _gl_cxxalias_dummy 497 # endif 498 #else 499 # define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \ 500 _GL_EXTERN_C int _gl_cxxalias_dummy 501 #endif 502 503 #endif /* _GL_CXXDEFS_H */ 504 505 /* The definition of _GL_WARN_ON_USE is copied here. */ 506 /* A C macro for emitting warnings if a function is used. 507 Copyright (C) 2010-2020 Free Software Foundation, Inc. 508 509 This program is free software: you can redistribute it and/or modify it 510 under the terms of the GNU General Public License as published 511 by the Free Software Foundation; either version 3 of the License, or 512 (at your option) any later version. 513 514 This program is distributed in the hope that it will be useful, 515 but WITHOUT ANY WARRANTY; without even the implied warranty of 516 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 517 General Public License for more details. 518 519 You should have received a copy of the GNU General Public License 520 along with this program. If not, see <https://www.gnu.org/licenses/>. */ 521 522 /* _GL_WARN_ON_USE (function, "literal string") issues a declaration 523 for FUNCTION which will then trigger a compiler warning containing 524 the text of "literal string" anywhere that function is called, if 525 supported by the compiler. If the compiler does not support this 526 feature, the macro expands to an unused extern declaration. 527 528 _GL_WARN_ON_USE_ATTRIBUTE ("literal string") expands to the 529 attribute used in _GL_WARN_ON_USE. If the compiler does not support 530 this feature, it expands to empty. 531 532 These macros are useful for marking a function as a potential 533 portability trap, with the intent that "literal string" include 534 instructions on the replacement function that should be used 535 instead. 536 _GL_WARN_ON_USE is for functions with 'extern' linkage. 537 _GL_WARN_ON_USE_ATTRIBUTE is for functions with 'static' or 'inline' 538 linkage. 539 540 However, one of the reasons that a function is a portability trap is 541 if it has the wrong signature. Declaring FUNCTION with a different 542 signature in C is a compilation error, so this macro must use the 543 same type as any existing declaration so that programs that avoid 544 the problematic FUNCTION do not fail to compile merely because they 545 included a header that poisoned the function. But this implies that 546 _GL_WARN_ON_USE is only safe to use if FUNCTION is known to already 547 have a declaration. Use of this macro implies that there must not 548 be any other macro hiding the declaration of FUNCTION; but 549 undefining FUNCTION first is part of the poisoning process anyway 550 (although for symbols that are provided only via a macro, the result 551 is a compilation error rather than a warning containing 552 "literal string"). Also note that in C++, it is only safe to use if 553 FUNCTION has no overloads. 554 555 For an example, it is possible to poison 'getline' by: 556 - adding a call to gl_WARN_ON_USE_PREPARE([[#include <stdio.h>]], 557 [getline]) in configure.ac, which potentially defines 558 HAVE_RAW_DECL_GETLINE 559 - adding this code to a header that wraps the system <stdio.h>: 560 #undef getline 561 #if HAVE_RAW_DECL_GETLINE 562 _GL_WARN_ON_USE (getline, "getline is required by POSIX 2008, but" 563 "not universally present; use the gnulib module getline"); 564 #endif 565 566 It is not possible to directly poison global variables. But it is 567 possible to write a wrapper accessor function, and poison that 568 (less common usage, like &environ, will cause a compilation error 569 rather than issue the nice warning, but the end result of informing 570 the developer about their portability problem is still achieved): 571 #if HAVE_RAW_DECL_ENVIRON 572 static char *** 573 rpl_environ (void) { return &environ; } 574 _GL_WARN_ON_USE (rpl_environ, "environ is not always properly declared"); 575 # undef environ 576 # define environ (*rpl_environ ()) 577 #endif 578 or better (avoiding contradictory use of 'static' and 'extern'): 579 #if HAVE_RAW_DECL_ENVIRON 580 static char *** 581 _GL_WARN_ON_USE_ATTRIBUTE ("environ is not always properly declared") 582 rpl_environ (void) { return &environ; } 583 # undef environ 584 # define environ (*rpl_environ ()) 585 #endif 586 */ 587 #ifndef _GL_WARN_ON_USE 588 589 # if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) 590 /* A compiler attribute is available in gcc versions 4.3.0 and later. */ 591 # define _GL_WARN_ON_USE(function, message) \ 592 extern __typeof__ (function) function __attribute__ ((__warning__ (message))) 593 # define _GL_WARN_ON_USE_ATTRIBUTE(message) \ 594 __attribute__ ((__warning__ (message))) 595 # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING 596 /* Verify the existence of the function. */ 597 # define _GL_WARN_ON_USE(function, message) \ 598 extern __typeof__ (function) function 599 # define _GL_WARN_ON_USE_ATTRIBUTE(message) 600 # else /* Unsupported. */ 601 # define _GL_WARN_ON_USE(function, message) \ 602 _GL_WARN_EXTERN_C int _gl_warn_on_use 603 # define _GL_WARN_ON_USE_ATTRIBUTE(message) 604 # endif 605 #endif 606 607 /* _GL_WARN_ON_USE_CXX (function, rettype, parameters_and_attributes, "string") 608 is like _GL_WARN_ON_USE (function, "string"), except that the function is 609 declared with the given prototype, consisting of return type, parameters, 610 and attributes. 611 This variant is useful for overloaded functions in C++. _GL_WARN_ON_USE does 612 not work in this case. */ 613 #ifndef _GL_WARN_ON_USE_CXX 614 # if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__) 615 # define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \ 616 extern rettype function parameters_and_attributes \ 617 __attribute__ ((__warning__ (msg))) 618 # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING 619 /* Verify the existence of the function. */ 620 # define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \ 621 extern rettype function parameters_and_attributes 622 # else /* Unsupported. */ 623 # define _GL_WARN_ON_USE_CXX(function,rettype,parameters_and_attributes,msg) \ 624 _GL_WARN_EXTERN_C int _gl_warn_on_use 625 # endif 626 #endif 627 628 /* _GL_WARN_EXTERN_C declaration; 629 performs the declaration with C linkage. */ 630 #ifndef _GL_WARN_EXTERN_C 631 # if defined __cplusplus 632 # define _GL_WARN_EXTERN_C extern "C" 633 # else 634 # define _GL_WARN_EXTERN_C extern 635 # endif 636 #endif 637 638 /* Declare overridden functions. */ 639 640 641 /* Return a piece of locale dependent information. 642 Note: The difference between nl_langinfo (CODESET) and locale_charset () 643 is that the latter normalizes the encoding names to GNU conventions. */ 644 645 #if 1 646 # if 0 647 # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 648 # undef nl_langinfo 649 # define nl_langinfo rpl_nl_langinfo 650 # endif 651 _GL_FUNCDECL_RPL (nl_langinfo, char *, (nl_item item)); 652 _GL_CXXALIAS_RPL (nl_langinfo, char *, (nl_item item)); 653 # else 654 # if !1 655 _GL_FUNCDECL_SYS (nl_langinfo, char *, (nl_item item)); 656 # endif 657 _GL_CXXALIAS_SYS (nl_langinfo, char *, (nl_item item)); 658 # endif 659 _GL_CXXALIASWARN (nl_langinfo); 660 #elif defined GNULIB_POSIXCHECK 661 # undef nl_langinfo 662 # if HAVE_RAW_DECL_NL_LANGINFO 663 _GL_WARN_ON_USE (nl_langinfo, "nl_langinfo is not portable - " 664 "use gnulib module nl_langinfo for portability"); 665 # endif 666 #endif 667 668 669 #endif /* _GL_LANGINFO_H */ 670 #endif /* _GL_LANGINFO_H */ 671