inttypes.h 43 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510
  1. /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
  2. /* Copyright (C) 2006-2022 Free Software Foundation, Inc.
  3. Written by Paul Eggert, Bruno Haible, Derek Price.
  4. This file is part of gnulib.
  5. This file is free software: you can redistribute it and/or modify
  6. it under the terms of the GNU Lesser General Public License as
  7. published by the Free Software Foundation; either version 2.1 of the
  8. License, or (at your option) any later version.
  9. This file is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU Lesser General Public License for more details.
  13. You should have received a copy of the GNU Lesser General Public License
  14. along with this program. If not, see <https://www.gnu.org/licenses/>. */
  15. /*
  16. * ISO C 99 <inttypes.h> for platforms that lack it.
  17. * <https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/inttypes.h.html>
  18. */
  19. #if __GNUC__ >= 3
  20. #pragma GCC system_header
  21. #endif
  22. /* Include the original <inttypes.h> if it exists, and if this file
  23. has not been included yet or if this file includes gnulib stdint.h
  24. which in turn includes this file.
  25. The include_next requires a split double-inclusion guard. */
  26. #if ! defined INTTYPES_H || defined _GL_JUST_INCLUDE_SYSTEM_INTTYPES_H
  27. # if 1
  28. /* Some pre-C++11 <stdint.h> implementations need this. */
  29. # if defined __cplusplus && ! defined __STDC_FORMAT_MACROS
  30. # define __STDC_FORMAT_MACROS 1
  31. # endif
  32. # include_next <inttypes.h>
  33. # define _GL_FINISHED_INCLUDING_SYSTEM_INTTYPES_H
  34. # endif
  35. #endif
  36. #if ! defined INTTYPES_H && ! defined _GL_JUST_INCLUDE_SYSTEM_INTTYPES_H
  37. #define INTTYPES_H
  38. /* Include <stdint.h> or the gnulib replacement.
  39. But avoid namespace pollution on glibc systems. */
  40. #ifndef __GLIBC__
  41. # include <stdint.h>
  42. #endif
  43. /* Get CHAR_BIT, INT_MAX, LONG_MAX, etc. */
  44. #include <limits.h>
  45. /* On mingw, __USE_MINGW_ANSI_STDIO only works if <stdio.h> is also included */
  46. #if defined _WIN32 && ! defined __CYGWIN__
  47. # include <stdio.h>
  48. #endif
  49. #if !(INT_MAX == 0x7fffffff && INT_MIN + INT_MAX == -1)
  50. # error "This file assumes that 'int' is 32-bit two's complement. Please report your platform and compiler to <bug-gnulib@gnu.org>."
  51. #endif
  52. /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
  53. /* C++ compatible function declaration macros.
  54. Copyright (C) 2010-2022 Free Software Foundation, Inc.
  55. This program is free software: you can redistribute it and/or modify it
  56. under the terms of the GNU Lesser General Public License as published
  57. by the Free Software Foundation; either version 2 of the License, or
  58. (at your option) any later version.
  59. This program is distributed in the hope that it will be useful,
  60. but WITHOUT ANY WARRANTY; without even the implied warranty of
  61. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  62. Lesser General Public License for more details.
  63. You should have received a copy of the GNU Lesser General Public License
  64. along with this program. If not, see <https://www.gnu.org/licenses/>. */
  65. #ifndef _GL_CXXDEFS_H
  66. #define _GL_CXXDEFS_H
  67. /* Begin/end the GNULIB_NAMESPACE namespace. */
  68. #if defined __cplusplus && defined GNULIB_NAMESPACE
  69. # define _GL_BEGIN_NAMESPACE namespace GNULIB_NAMESPACE {
  70. # define _GL_END_NAMESPACE }
  71. #else
  72. # define _GL_BEGIN_NAMESPACE
  73. # define _GL_END_NAMESPACE
  74. #endif
  75. /* The three most frequent use cases of these macros are:
  76. * For providing a substitute for a function that is missing on some
  77. platforms, but is declared and works fine on the platforms on which
  78. it exists:
  79. #if @GNULIB_FOO@
  80. # if !@HAVE_FOO@
  81. _GL_FUNCDECL_SYS (foo, ...);
  82. # endif
  83. _GL_CXXALIAS_SYS (foo, ...);
  84. _GL_CXXALIASWARN (foo);
  85. #elif defined GNULIB_POSIXCHECK
  86. ...
  87. #endif
  88. * For providing a replacement for a function that exists on all platforms,
  89. but is broken/insufficient and needs to be replaced on some platforms:
  90. #if @GNULIB_FOO@
  91. # if @REPLACE_FOO@
  92. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  93. # undef foo
  94. # define foo rpl_foo
  95. # endif
  96. _GL_FUNCDECL_RPL (foo, ...);
  97. _GL_CXXALIAS_RPL (foo, ...);
  98. # else
  99. _GL_CXXALIAS_SYS (foo, ...);
  100. # endif
  101. _GL_CXXALIASWARN (foo);
  102. #elif defined GNULIB_POSIXCHECK
  103. ...
  104. #endif
  105. * For providing a replacement for a function that exists on some platforms
  106. but is broken/insufficient and needs to be replaced on some of them and
  107. is additionally either missing or undeclared on some other platforms:
  108. #if @GNULIB_FOO@
  109. # if @REPLACE_FOO@
  110. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  111. # undef foo
  112. # define foo rpl_foo
  113. # endif
  114. _GL_FUNCDECL_RPL (foo, ...);
  115. _GL_CXXALIAS_RPL (foo, ...);
  116. # else
  117. # if !@HAVE_FOO@ or if !@HAVE_DECL_FOO@
  118. _GL_FUNCDECL_SYS (foo, ...);
  119. # endif
  120. _GL_CXXALIAS_SYS (foo, ...);
  121. # endif
  122. _GL_CXXALIASWARN (foo);
  123. #elif defined GNULIB_POSIXCHECK
  124. ...
  125. #endif
  126. */
  127. /* _GL_EXTERN_C declaration;
  128. performs the declaration with C linkage. */
  129. #if defined __cplusplus
  130. # define _GL_EXTERN_C extern "C"
  131. #else
  132. # define _GL_EXTERN_C extern
  133. #endif
  134. /* _GL_FUNCDECL_RPL (func, rettype, parameters_and_attributes);
  135. declares a replacement function, named rpl_func, with the given prototype,
  136. consisting of return type, parameters, and attributes.
  137. Example:
  138. _GL_FUNCDECL_RPL (open, int, (const char *filename, int flags, ...)
  139. _GL_ARG_NONNULL ((1)));
  140. */
  141. #define _GL_FUNCDECL_RPL(func,rettype,parameters_and_attributes) \
  142. _GL_FUNCDECL_RPL_1 (rpl_##func, rettype, parameters_and_attributes)
  143. #define _GL_FUNCDECL_RPL_1(rpl_func,rettype,parameters_and_attributes) \
  144. _GL_EXTERN_C rettype rpl_func parameters_and_attributes
  145. /* _GL_FUNCDECL_SYS (func, rettype, parameters_and_attributes);
  146. declares the system function, named func, with the given prototype,
  147. consisting of return type, parameters, and attributes.
  148. Example:
  149. _GL_FUNCDECL_SYS (open, int, (const char *filename, int flags, ...)
  150. _GL_ARG_NONNULL ((1)));
  151. */
  152. #define _GL_FUNCDECL_SYS(func,rettype,parameters_and_attributes) \
  153. _GL_EXTERN_C rettype func parameters_and_attributes
  154. /* _GL_CXXALIAS_RPL (func, rettype, parameters);
  155. declares a C++ alias called GNULIB_NAMESPACE::func
  156. that redirects to rpl_func, if GNULIB_NAMESPACE is defined.
  157. Example:
  158. _GL_CXXALIAS_RPL (open, int, (const char *filename, int flags, ...));
  159. Wrapping rpl_func in an object with an inline conversion operator
  160. avoids a reference to rpl_func unless GNULIB_NAMESPACE::func is
  161. actually used in the program. */
  162. #define _GL_CXXALIAS_RPL(func,rettype,parameters) \
  163. _GL_CXXALIAS_RPL_1 (func, rpl_##func, rettype, parameters)
  164. #if defined __cplusplus && defined GNULIB_NAMESPACE
  165. # define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
  166. namespace GNULIB_NAMESPACE \
  167. { \
  168. static const struct _gl_ ## func ## _wrapper \
  169. { \
  170. typedef rettype (*type) parameters; \
  171. \
  172. inline operator type () const \
  173. { \
  174. return ::rpl_func; \
  175. } \
  176. } func = {}; \
  177. } \
  178. _GL_EXTERN_C int _gl_cxxalias_dummy
  179. #else
  180. # define _GL_CXXALIAS_RPL_1(func,rpl_func,rettype,parameters) \
  181. _GL_EXTERN_C int _gl_cxxalias_dummy
  182. #endif
  183. /* _GL_CXXALIAS_MDA (func, rettype, parameters);
  184. is to be used when func is a Microsoft deprecated alias, on native Windows.
  185. It declares a C++ alias called GNULIB_NAMESPACE::func
  186. that redirects to _func, if GNULIB_NAMESPACE is defined.
  187. Example:
  188. _GL_CXXALIAS_MDA (open, int, (const char *filename, int flags, ...));
  189. */
  190. #define _GL_CXXALIAS_MDA(func,rettype,parameters) \
  191. _GL_CXXALIAS_RPL_1 (func, _##func, rettype, parameters)
  192. /* _GL_CXXALIAS_RPL_CAST_1 (func, rpl_func, rettype, parameters);
  193. is like _GL_CXXALIAS_RPL_1 (func, rpl_func, rettype, parameters);
  194. except that the C function rpl_func may have a slightly different
  195. declaration. A cast is used to silence the "invalid conversion" error
  196. that would otherwise occur. */
  197. #if defined __cplusplus && defined GNULIB_NAMESPACE
  198. # define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
  199. namespace GNULIB_NAMESPACE \
  200. { \
  201. static const struct _gl_ ## func ## _wrapper \
  202. { \
  203. typedef rettype (*type) parameters; \
  204. \
  205. inline operator type () const \
  206. { \
  207. return reinterpret_cast<type>(::rpl_func); \
  208. } \
  209. } func = {}; \
  210. } \
  211. _GL_EXTERN_C int _gl_cxxalias_dummy
  212. #else
  213. # define _GL_CXXALIAS_RPL_CAST_1(func,rpl_func,rettype,parameters) \
  214. _GL_EXTERN_C int _gl_cxxalias_dummy
  215. #endif
  216. /* _GL_CXXALIAS_MDA_CAST (func, rettype, parameters);
  217. is like _GL_CXXALIAS_MDA (func, rettype, parameters);
  218. except that the C function func may have a slightly different declaration.
  219. A cast is used to silence the "invalid conversion" error that would
  220. otherwise occur. */
  221. #define _GL_CXXALIAS_MDA_CAST(func,rettype,parameters) \
  222. _GL_CXXALIAS_RPL_CAST_1 (func, _##func, rettype, parameters)
  223. /* _GL_CXXALIAS_SYS (func, rettype, parameters);
  224. declares a C++ alias called GNULIB_NAMESPACE::func
  225. that redirects to the system provided function func, if GNULIB_NAMESPACE
  226. is defined.
  227. Example:
  228. _GL_CXXALIAS_SYS (open, int, (const char *filename, int flags, ...));
  229. Wrapping func in an object with an inline conversion operator
  230. avoids a reference to func unless GNULIB_NAMESPACE::func is
  231. actually used in the program. */
  232. #if defined __cplusplus && defined GNULIB_NAMESPACE
  233. # define _GL_CXXALIAS_SYS(func,rettype,parameters) \
  234. namespace GNULIB_NAMESPACE \
  235. { \
  236. static const struct _gl_ ## func ## _wrapper \
  237. { \
  238. typedef rettype (*type) parameters; \
  239. \
  240. inline operator type () const \
  241. { \
  242. return ::func; \
  243. } \
  244. } func = {}; \
  245. } \
  246. _GL_EXTERN_C int _gl_cxxalias_dummy
  247. #else
  248. # define _GL_CXXALIAS_SYS(func,rettype,parameters) \
  249. _GL_EXTERN_C int _gl_cxxalias_dummy
  250. #endif
  251. /* _GL_CXXALIAS_SYS_CAST (func, rettype, parameters);
  252. is like _GL_CXXALIAS_SYS (func, rettype, parameters);
  253. except that the C function func may have a slightly different declaration.
  254. A cast is used to silence the "invalid conversion" error that would
  255. otherwise occur. */
  256. #if defined __cplusplus && defined GNULIB_NAMESPACE
  257. # define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
  258. namespace GNULIB_NAMESPACE \
  259. { \
  260. static const struct _gl_ ## func ## _wrapper \
  261. { \
  262. typedef rettype (*type) parameters; \
  263. \
  264. inline operator type () const \
  265. { \
  266. return reinterpret_cast<type>(::func); \
  267. } \
  268. } func = {}; \
  269. } \
  270. _GL_EXTERN_C int _gl_cxxalias_dummy
  271. #else
  272. # define _GL_CXXALIAS_SYS_CAST(func,rettype,parameters) \
  273. _GL_EXTERN_C int _gl_cxxalias_dummy
  274. #endif
  275. /* _GL_CXXALIAS_SYS_CAST2 (func, rettype, parameters, rettype2, parameters2);
  276. is like _GL_CXXALIAS_SYS (func, rettype, parameters);
  277. except that the C function is picked among a set of overloaded functions,
  278. namely the one with rettype2 and parameters2. Two consecutive casts
  279. are used to silence the "cannot find a match" and "invalid conversion"
  280. errors that would otherwise occur. */
  281. #if defined __cplusplus && defined GNULIB_NAMESPACE
  282. /* The outer cast must be a reinterpret_cast.
  283. The inner cast: When the function is defined as a set of overloaded
  284. functions, it works as a static_cast<>, choosing the designated variant.
  285. When the function is defined as a single variant, it works as a
  286. reinterpret_cast<>. The parenthesized cast syntax works both ways. */
  287. # define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
  288. namespace GNULIB_NAMESPACE \
  289. { \
  290. static const struct _gl_ ## func ## _wrapper \
  291. { \
  292. typedef rettype (*type) parameters; \
  293. \
  294. inline operator type () const \
  295. { \
  296. return reinterpret_cast<type>((rettype2 (*) parameters2)(::func)); \
  297. } \
  298. } func = {}; \
  299. } \
  300. _GL_EXTERN_C int _gl_cxxalias_dummy
  301. #else
  302. # define _GL_CXXALIAS_SYS_CAST2(func,rettype,parameters,rettype2,parameters2) \
  303. _GL_EXTERN_C int _gl_cxxalias_dummy
  304. #endif
  305. /* _GL_CXXALIASWARN (func);
  306. causes a warning to be emitted when ::func is used but not when
  307. GNULIB_NAMESPACE::func is used. func must be defined without overloaded
  308. variants. */
  309. #if defined __cplusplus && defined GNULIB_NAMESPACE
  310. # define _GL_CXXALIASWARN(func) \
  311. _GL_CXXALIASWARN_1 (func, GNULIB_NAMESPACE)
  312. # define _GL_CXXALIASWARN_1(func,namespace) \
  313. _GL_CXXALIASWARN_2 (func, namespace)
  314. /* To work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
  315. we enable the warning only when not optimizing. */
  316. # if !(defined __GNUC__ && !defined __clang__ && __OPTIMIZE__)
  317. # define _GL_CXXALIASWARN_2(func,namespace) \
  318. _GL_WARN_ON_USE (func, \
  319. "The symbol ::" #func " refers to the system function. " \
  320. "Use " #namespace "::" #func " instead.")
  321. # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
  322. # define _GL_CXXALIASWARN_2(func,namespace) \
  323. extern __typeof__ (func) func
  324. # else
  325. # define _GL_CXXALIASWARN_2(func,namespace) \
  326. _GL_EXTERN_C int _gl_cxxalias_dummy
  327. # endif
  328. #else
  329. # define _GL_CXXALIASWARN(func) \
  330. _GL_EXTERN_C int _gl_cxxalias_dummy
  331. #endif
  332. /* _GL_CXXALIASWARN1 (func, rettype, parameters_and_attributes);
  333. causes a warning to be emitted when the given overloaded variant of ::func
  334. is used but not when GNULIB_NAMESPACE::func is used. */
  335. #if defined __cplusplus && defined GNULIB_NAMESPACE
  336. # define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
  337. _GL_CXXALIASWARN1_1 (func, rettype, parameters_and_attributes, \
  338. GNULIB_NAMESPACE)
  339. # define _GL_CXXALIASWARN1_1(func,rettype,parameters_and_attributes,namespace) \
  340. _GL_CXXALIASWARN1_2 (func, rettype, parameters_and_attributes, namespace)
  341. /* To work around GCC bug <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=43881>,
  342. we enable the warning only when not optimizing. */
  343. # if !(defined __GNUC__ && !defined __clang__ && __OPTIMIZE__)
  344. # define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
  345. _GL_WARN_ON_USE_CXX (func, rettype, rettype, parameters_and_attributes, \
  346. "The symbol ::" #func " refers to the system function. " \
  347. "Use " #namespace "::" #func " instead.")
  348. # else
  349. # define _GL_CXXALIASWARN1_2(func,rettype,parameters_and_attributes,namespace) \
  350. _GL_EXTERN_C int _gl_cxxalias_dummy
  351. # endif
  352. #else
  353. # define _GL_CXXALIASWARN1(func,rettype,parameters_and_attributes) \
  354. _GL_EXTERN_C int _gl_cxxalias_dummy
  355. #endif
  356. #endif /* _GL_CXXDEFS_H */
  357. /* The definition of _GL_ARG_NONNULL is copied here. */
  358. /* A C macro for declaring that specific arguments must not be NULL.
  359. Copyright (C) 2009-2022 Free Software Foundation, Inc.
  360. This program is free software: you can redistribute it and/or modify it
  361. under the terms of the GNU Lesser General Public License as published
  362. by the Free Software Foundation; either version 2 of the License, or
  363. (at your option) any later version.
  364. This program is distributed in the hope that it will be useful,
  365. but WITHOUT ANY WARRANTY; without even the implied warranty of
  366. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  367. Lesser General Public License for more details.
  368. You should have received a copy of the GNU Lesser General Public License
  369. along with this program. If not, see <https://www.gnu.org/licenses/>. */
  370. /* _GL_ARG_NONNULL((n,...,m)) tells the compiler and static analyzer tools
  371. that the values passed as arguments n, ..., m must be non-NULL pointers.
  372. n = 1 stands for the first argument, n = 2 for the second argument etc. */
  373. #ifndef _GL_ARG_NONNULL
  374. # if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || defined __clang__
  375. # define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params))
  376. # else
  377. # define _GL_ARG_NONNULL(params)
  378. # endif
  379. #endif
  380. /* The definition of _GL_WARN_ON_USE is copied here. */
  381. /* A C macro for emitting warnings if a function is used.
  382. Copyright (C) 2010-2022 Free Software Foundation, Inc.
  383. This program is free software: you can redistribute it and/or modify it
  384. under the terms of the GNU Lesser General Public License as published
  385. by the Free Software Foundation; either version 2 of the License, or
  386. (at your option) any later version.
  387. This program is distributed in the hope that it will be useful,
  388. but WITHOUT ANY WARRANTY; without even the implied warranty of
  389. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  390. Lesser General Public License for more details.
  391. You should have received a copy of the GNU Lesser General Public License
  392. along with this program. If not, see <https://www.gnu.org/licenses/>. */
  393. /* _GL_WARN_ON_USE (function, "literal string") issues a declaration
  394. for FUNCTION which will then trigger a compiler warning containing
  395. the text of "literal string" anywhere that function is called, if
  396. supported by the compiler. If the compiler does not support this
  397. feature, the macro expands to an unused extern declaration.
  398. _GL_WARN_ON_USE_ATTRIBUTE ("literal string") expands to the
  399. attribute used in _GL_WARN_ON_USE. If the compiler does not support
  400. this feature, it expands to empty.
  401. These macros are useful for marking a function as a potential
  402. portability trap, with the intent that "literal string" include
  403. instructions on the replacement function that should be used
  404. instead.
  405. _GL_WARN_ON_USE is for functions with 'extern' linkage.
  406. _GL_WARN_ON_USE_ATTRIBUTE is for functions with 'static' or 'inline'
  407. linkage.
  408. However, one of the reasons that a function is a portability trap is
  409. if it has the wrong signature. Declaring FUNCTION with a different
  410. signature in C is a compilation error, so this macro must use the
  411. same type as any existing declaration so that programs that avoid
  412. the problematic FUNCTION do not fail to compile merely because they
  413. included a header that poisoned the function. But this implies that
  414. _GL_WARN_ON_USE is only safe to use if FUNCTION is known to already
  415. have a declaration. Use of this macro implies that there must not
  416. be any other macro hiding the declaration of FUNCTION; but
  417. undefining FUNCTION first is part of the poisoning process anyway
  418. (although for symbols that are provided only via a macro, the result
  419. is a compilation error rather than a warning containing
  420. "literal string"). Also note that in C++, it is only safe to use if
  421. FUNCTION has no overloads.
  422. For an example, it is possible to poison 'getline' by:
  423. - adding a call to gl_WARN_ON_USE_PREPARE([[#include <stdio.h>]],
  424. [getline]) in configure.ac, which potentially defines
  425. HAVE_RAW_DECL_GETLINE
  426. - adding this code to a header that wraps the system <stdio.h>:
  427. #undef getline
  428. #if HAVE_RAW_DECL_GETLINE
  429. _GL_WARN_ON_USE (getline, "getline is required by POSIX 2008, but"
  430. "not universally present; use the gnulib module getline");
  431. #endif
  432. It is not possible to directly poison global variables. But it is
  433. possible to write a wrapper accessor function, and poison that
  434. (less common usage, like &environ, will cause a compilation error
  435. rather than issue the nice warning, but the end result of informing
  436. the developer about their portability problem is still achieved):
  437. #if HAVE_RAW_DECL_ENVIRON
  438. static char ***
  439. rpl_environ (void) { return &environ; }
  440. _GL_WARN_ON_USE (rpl_environ, "environ is not always properly declared");
  441. # undef environ
  442. # define environ (*rpl_environ ())
  443. #endif
  444. or better (avoiding contradictory use of 'static' and 'extern'):
  445. #if HAVE_RAW_DECL_ENVIRON
  446. static char ***
  447. _GL_WARN_ON_USE_ATTRIBUTE ("environ is not always properly declared")
  448. rpl_environ (void) { return &environ; }
  449. # undef environ
  450. # define environ (*rpl_environ ())
  451. #endif
  452. */
  453. #ifndef _GL_WARN_ON_USE
  454. # if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
  455. /* A compiler attribute is available in gcc versions 4.3.0 and later. */
  456. # define _GL_WARN_ON_USE(function, message) \
  457. _GL_WARN_EXTERN_C __typeof__ (function) function __attribute__ ((__warning__ (message)))
  458. # define _GL_WARN_ON_USE_ATTRIBUTE(message) \
  459. __attribute__ ((__warning__ (message)))
  460. # elif __clang_major__ >= 4
  461. /* Another compiler attribute is available in clang. */
  462. # define _GL_WARN_ON_USE(function, message) \
  463. _GL_WARN_EXTERN_C __typeof__ (function) function \
  464. __attribute__ ((__diagnose_if__ (1, message, "warning")))
  465. # define _GL_WARN_ON_USE_ATTRIBUTE(message) \
  466. __attribute__ ((__diagnose_if__ (1, message, "warning")))
  467. # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
  468. /* Verify the existence of the function. */
  469. # define _GL_WARN_ON_USE(function, message) \
  470. _GL_WARN_EXTERN_C __typeof__ (function) function
  471. # define _GL_WARN_ON_USE_ATTRIBUTE(message)
  472. # else /* Unsupported. */
  473. # define _GL_WARN_ON_USE(function, message) \
  474. _GL_WARN_EXTERN_C int _gl_warn_on_use
  475. # define _GL_WARN_ON_USE_ATTRIBUTE(message)
  476. # endif
  477. #endif
  478. /* _GL_WARN_ON_USE_CXX (function, rettype_gcc, rettype_clang, parameters_and_attributes, "message")
  479. is like _GL_WARN_ON_USE (function, "message"), except that in C++ mode the
  480. function is declared with the given prototype, consisting of return type,
  481. parameters, and attributes.
  482. This variant is useful for overloaded functions in C++. _GL_WARN_ON_USE does
  483. not work in this case. */
  484. #ifndef _GL_WARN_ON_USE_CXX
  485. # if !defined __cplusplus
  486. # define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \
  487. _GL_WARN_ON_USE (function, msg)
  488. # else
  489. # if 4 < __GNUC__ || (__GNUC__ == 4 && 3 <= __GNUC_MINOR__)
  490. /* A compiler attribute is available in gcc versions 4.3.0 and later. */
  491. # define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \
  492. extern rettype_gcc function parameters_and_attributes \
  493. __attribute__ ((__warning__ (msg)))
  494. # elif __clang_major__ >= 4
  495. /* Another compiler attribute is available in clang. */
  496. # define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \
  497. extern rettype_clang function parameters_and_attributes \
  498. __attribute__ ((__diagnose_if__ (1, msg, "warning")))
  499. # elif __GNUC__ >= 3 && GNULIB_STRICT_CHECKING
  500. /* Verify the existence of the function. */
  501. # define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \
  502. extern rettype_gcc function parameters_and_attributes
  503. # else /* Unsupported. */
  504. # define _GL_WARN_ON_USE_CXX(function,rettype_gcc,rettype_clang,parameters_and_attributes,msg) \
  505. _GL_WARN_EXTERN_C int _gl_warn_on_use
  506. # endif
  507. # endif
  508. #endif
  509. /* _GL_WARN_EXTERN_C declaration;
  510. performs the declaration with C linkage. */
  511. #ifndef _GL_WARN_EXTERN_C
  512. # if defined __cplusplus
  513. # define _GL_WARN_EXTERN_C extern "C"
  514. # else
  515. # define _GL_WARN_EXTERN_C extern
  516. # endif
  517. #endif
  518. /* 7.8.1 Macros for format specifiers */
  519. #if defined _TNS_R_TARGET
  520. /* Tandem NonStop R series and compatible platforms released before
  521. July 2005 support %Ld but not %lld. */
  522. # define _LONG_LONG_FORMAT_PREFIX "L"
  523. #else
  524. # define _LONG_LONG_FORMAT_PREFIX "ll"
  525. #endif
  526. #if !defined PRId8
  527. # ifdef INT8_MAX
  528. # define PRId8 "d"
  529. # endif
  530. #endif
  531. #if !defined PRIi8
  532. # ifdef INT8_MAX
  533. # define PRIi8 "i"
  534. # endif
  535. #endif
  536. #if !defined PRIo8
  537. # ifdef UINT8_MAX
  538. # define PRIo8 "o"
  539. # endif
  540. #endif
  541. #if !defined PRIu8
  542. # ifdef UINT8_MAX
  543. # define PRIu8 "u"
  544. # endif
  545. #endif
  546. #if !defined PRIx8
  547. # ifdef UINT8_MAX
  548. # define PRIx8 "x"
  549. # endif
  550. #endif
  551. #if !defined PRIX8
  552. # ifdef UINT8_MAX
  553. # define PRIX8 "X"
  554. # endif
  555. #endif
  556. #if !defined PRId16
  557. # ifdef INT16_MAX
  558. # define PRId16 "d"
  559. # endif
  560. #endif
  561. #if !defined PRIi16
  562. # ifdef INT16_MAX
  563. # define PRIi16 "i"
  564. # endif
  565. #endif
  566. #if !defined PRIo16
  567. # ifdef UINT16_MAX
  568. # define PRIo16 "o"
  569. # endif
  570. #endif
  571. #if !defined PRIu16
  572. # ifdef UINT16_MAX
  573. # define PRIu16 "u"
  574. # endif
  575. #endif
  576. #if !defined PRIx16
  577. # ifdef UINT16_MAX
  578. # define PRIx16 "x"
  579. # endif
  580. #endif
  581. #if !defined PRIX16
  582. # ifdef UINT16_MAX
  583. # define PRIX16 "X"
  584. # endif
  585. #endif
  586. #if !defined PRId32
  587. # ifdef INT32_MAX
  588. # define PRId32 "d"
  589. # endif
  590. #endif
  591. #if !defined PRIi32
  592. # ifdef INT32_MAX
  593. # define PRIi32 "i"
  594. # endif
  595. #endif
  596. #if !defined PRIo32
  597. # ifdef UINT32_MAX
  598. # define PRIo32 "o"
  599. # endif
  600. #endif
  601. #if !defined PRIu32
  602. # ifdef UINT32_MAX
  603. # define PRIu32 "u"
  604. # endif
  605. #endif
  606. #if !defined PRIx32
  607. # ifdef UINT32_MAX
  608. # define PRIx32 "x"
  609. # endif
  610. #endif
  611. #if !defined PRIX32
  612. # ifdef UINT32_MAX
  613. # define PRIX32 "X"
  614. # endif
  615. #endif
  616. #ifdef INT64_MAX
  617. # if (0 ? defined _LP64 : defined _LP64)
  618. # define _PRI64_PREFIX "l"
  619. # elif defined _MSC_VER || defined __MINGW32__
  620. # define _PRI64_PREFIX "I64"
  621. # elif LONG_MAX >> 30 == 1
  622. # define _PRI64_PREFIX _LONG_LONG_FORMAT_PREFIX
  623. # endif
  624. # if !defined PRId64
  625. # define PRId64 _PRI64_PREFIX "d"
  626. # endif
  627. # if !defined PRIi64
  628. # define PRIi64 _PRI64_PREFIX "i"
  629. # endif
  630. #endif
  631. #ifdef UINT64_MAX
  632. # if (0 ? defined _LP64 : defined _LP64)
  633. # define _PRIu64_PREFIX "l"
  634. # elif defined _MSC_VER || defined __MINGW32__
  635. # define _PRIu64_PREFIX "I64"
  636. # elif ULONG_MAX >> 31 == 1
  637. # define _PRIu64_PREFIX _LONG_LONG_FORMAT_PREFIX
  638. # endif
  639. # if !defined PRIo64
  640. # define PRIo64 _PRIu64_PREFIX "o"
  641. # endif
  642. # if !defined PRIu64
  643. # define PRIu64 _PRIu64_PREFIX "u"
  644. # endif
  645. # if !defined PRIx64
  646. # define PRIx64 _PRIu64_PREFIX "x"
  647. # endif
  648. # if !defined PRIX64
  649. # define PRIX64 _PRIu64_PREFIX "X"
  650. # endif
  651. #endif
  652. #if !defined PRIdLEAST8
  653. # define PRIdLEAST8 "d"
  654. #endif
  655. #if !defined PRIiLEAST8
  656. # define PRIiLEAST8 "i"
  657. #endif
  658. #if !defined PRIoLEAST8
  659. # define PRIoLEAST8 "o"
  660. #endif
  661. #if !defined PRIuLEAST8
  662. # define PRIuLEAST8 "u"
  663. #endif
  664. #if !defined PRIxLEAST8
  665. # define PRIxLEAST8 "x"
  666. #endif
  667. #if !defined PRIXLEAST8
  668. # define PRIXLEAST8 "X"
  669. #endif
  670. #if !defined PRIdLEAST16
  671. # define PRIdLEAST16 "d"
  672. #endif
  673. #if !defined PRIiLEAST16
  674. # define PRIiLEAST16 "i"
  675. #endif
  676. #if !defined PRIoLEAST16
  677. # define PRIoLEAST16 "o"
  678. #endif
  679. #if !defined PRIuLEAST16
  680. # define PRIuLEAST16 "u"
  681. #endif
  682. #if !defined PRIxLEAST16
  683. # define PRIxLEAST16 "x"
  684. #endif
  685. #if !defined PRIXLEAST16
  686. # define PRIXLEAST16 "X"
  687. #endif
  688. #if !defined PRIdLEAST32
  689. # define PRIdLEAST32 "d"
  690. #endif
  691. #if !defined PRIiLEAST32
  692. # define PRIiLEAST32 "i"
  693. #endif
  694. #if !defined PRIoLEAST32
  695. # define PRIoLEAST32 "o"
  696. #endif
  697. #if !defined PRIuLEAST32
  698. # define PRIuLEAST32 "u"
  699. #endif
  700. #if !defined PRIxLEAST32
  701. # define PRIxLEAST32 "x"
  702. #endif
  703. #if !defined PRIXLEAST32
  704. # define PRIXLEAST32 "X"
  705. #endif
  706. #ifdef INT64_MAX
  707. # if !defined PRIdLEAST64
  708. # define PRIdLEAST64 PRId64
  709. # endif
  710. # if !defined PRIiLEAST64
  711. # define PRIiLEAST64 PRIi64
  712. # endif
  713. #endif
  714. #ifdef UINT64_MAX
  715. # if !defined PRIoLEAST64
  716. # define PRIoLEAST64 PRIo64
  717. # endif
  718. # if !defined PRIuLEAST64
  719. # define PRIuLEAST64 PRIu64
  720. # endif
  721. # if !defined PRIxLEAST64
  722. # define PRIxLEAST64 PRIx64
  723. # endif
  724. # if !defined PRIXLEAST64
  725. # define PRIXLEAST64 PRIX64
  726. # endif
  727. #endif
  728. #if !defined PRIdFAST8
  729. # if INT_FAST8_MAX > INT32_MAX
  730. # define PRIdFAST8 PRId64
  731. # else
  732. # define PRIdFAST8 "d"
  733. # endif
  734. #endif
  735. #if !defined PRIiFAST8
  736. # if INT_FAST8_MAX > INT32_MAX
  737. # define PRIiFAST8 PRIi64
  738. # else
  739. # define PRIiFAST8 "i"
  740. # endif
  741. #endif
  742. #if !defined PRIoFAST8
  743. # if UINT_FAST8_MAX > UINT32_MAX
  744. # define PRIoFAST8 PRIo64
  745. # else
  746. # define PRIoFAST8 "o"
  747. # endif
  748. #endif
  749. #if !defined PRIuFAST8
  750. # if UINT_FAST8_MAX > UINT32_MAX
  751. # define PRIuFAST8 PRIu64
  752. # else
  753. # define PRIuFAST8 "u"
  754. # endif
  755. #endif
  756. #if !defined PRIxFAST8
  757. # if UINT_FAST8_MAX > UINT32_MAX
  758. # define PRIxFAST8 PRIx64
  759. # else
  760. # define PRIxFAST8 "x"
  761. # endif
  762. #endif
  763. #if !defined PRIXFAST8
  764. # if UINT_FAST8_MAX > UINT32_MAX
  765. # define PRIXFAST8 PRIX64
  766. # else
  767. # define PRIXFAST8 "X"
  768. # endif
  769. #endif
  770. #if !defined PRIdFAST16
  771. # if INT_FAST16_MAX > INT32_MAX
  772. # define PRIdFAST16 PRId64
  773. # else
  774. # define PRIdFAST16 "d"
  775. # endif
  776. #endif
  777. #if !defined PRIiFAST16
  778. # if INT_FAST16_MAX > INT32_MAX
  779. # define PRIiFAST16 PRIi64
  780. # else
  781. # define PRIiFAST16 "i"
  782. # endif
  783. #endif
  784. #if !defined PRIoFAST16
  785. # if UINT_FAST16_MAX > UINT32_MAX
  786. # define PRIoFAST16 PRIo64
  787. # else
  788. # define PRIoFAST16 "o"
  789. # endif
  790. #endif
  791. #if !defined PRIuFAST16
  792. # if UINT_FAST16_MAX > UINT32_MAX
  793. # define PRIuFAST16 PRIu64
  794. # else
  795. # define PRIuFAST16 "u"
  796. # endif
  797. #endif
  798. #if !defined PRIxFAST16
  799. # if UINT_FAST16_MAX > UINT32_MAX
  800. # define PRIxFAST16 PRIx64
  801. # else
  802. # define PRIxFAST16 "x"
  803. # endif
  804. #endif
  805. #if !defined PRIXFAST16
  806. # if UINT_FAST16_MAX > UINT32_MAX
  807. # define PRIXFAST16 PRIX64
  808. # else
  809. # define PRIXFAST16 "X"
  810. # endif
  811. #endif
  812. #if !defined PRIdFAST32
  813. # if INT_FAST32_MAX > INT32_MAX
  814. # define PRIdFAST32 PRId64
  815. # else
  816. # define PRIdFAST32 "d"
  817. # endif
  818. #endif
  819. #if !defined PRIiFAST32
  820. # if INT_FAST32_MAX > INT32_MAX
  821. # define PRIiFAST32 PRIi64
  822. # else
  823. # define PRIiFAST32 "i"
  824. # endif
  825. #endif
  826. #if !defined PRIoFAST32
  827. # if UINT_FAST32_MAX > UINT32_MAX
  828. # define PRIoFAST32 PRIo64
  829. # else
  830. # define PRIoFAST32 "o"
  831. # endif
  832. #endif
  833. #if !defined PRIuFAST32
  834. # if UINT_FAST32_MAX > UINT32_MAX
  835. # define PRIuFAST32 PRIu64
  836. # else
  837. # define PRIuFAST32 "u"
  838. # endif
  839. #endif
  840. #if !defined PRIxFAST32
  841. # if UINT_FAST32_MAX > UINT32_MAX
  842. # define PRIxFAST32 PRIx64
  843. # else
  844. # define PRIxFAST32 "x"
  845. # endif
  846. #endif
  847. #if !defined PRIXFAST32
  848. # if UINT_FAST32_MAX > UINT32_MAX
  849. # define PRIXFAST32 PRIX64
  850. # else
  851. # define PRIXFAST32 "X"
  852. # endif
  853. #endif
  854. #ifdef INT64_MAX
  855. # if !defined PRIdFAST64
  856. # define PRIdFAST64 PRId64
  857. # endif
  858. # if !defined PRIiFAST64
  859. # define PRIiFAST64 PRIi64
  860. # endif
  861. #endif
  862. #ifdef UINT64_MAX
  863. # if !defined PRIoFAST64
  864. # define PRIoFAST64 PRIo64
  865. # endif
  866. # if !defined PRIuFAST64
  867. # define PRIuFAST64 PRIu64
  868. # endif
  869. # if !defined PRIxFAST64
  870. # define PRIxFAST64 PRIx64
  871. # endif
  872. # if !defined PRIXFAST64
  873. # define PRIXFAST64 PRIX64
  874. # endif
  875. #endif
  876. #if !defined PRIdMAX
  877. # if 1
  878. # define PRIdMAX PRId64
  879. # else
  880. # define PRIdMAX "ld"
  881. # endif
  882. #endif
  883. #if !defined PRIiMAX
  884. # if 1
  885. # define PRIiMAX PRIi64
  886. # else
  887. # define PRIiMAX "li"
  888. # endif
  889. #endif
  890. #if !defined PRIoMAX
  891. # if 1
  892. # define PRIoMAX PRIo64
  893. # else
  894. # define PRIoMAX "lo"
  895. # endif
  896. #endif
  897. #if !defined PRIuMAX
  898. # if 1
  899. # define PRIuMAX PRIu64
  900. # else
  901. # define PRIuMAX "lu"
  902. # endif
  903. #endif
  904. #if !defined PRIxMAX
  905. # if 1
  906. # define PRIxMAX PRIx64
  907. # else
  908. # define PRIxMAX "lx"
  909. # endif
  910. #endif
  911. #if !defined PRIXMAX
  912. # if 1
  913. # define PRIXMAX PRIX64
  914. # else
  915. # define PRIXMAX "lX"
  916. # endif
  917. #endif
  918. #if !defined PRIdPTR
  919. # ifdef INTPTR_MAX
  920. # define PRIdPTR __PRIPTR_PREFIX "d"
  921. # endif
  922. #endif
  923. #if !defined PRIiPTR
  924. # ifdef INTPTR_MAX
  925. # define PRIiPTR __PRIPTR_PREFIX "i"
  926. # endif
  927. #endif
  928. #if !defined PRIoPTR
  929. # ifdef UINTPTR_MAX
  930. # define PRIoPTR __PRIPTR_PREFIX "o"
  931. # endif
  932. #endif
  933. #if !defined PRIuPTR
  934. # ifdef UINTPTR_MAX
  935. # define PRIuPTR __PRIPTR_PREFIX "u"
  936. # endif
  937. #endif
  938. #if !defined PRIxPTR
  939. # ifdef UINTPTR_MAX
  940. # define PRIxPTR __PRIPTR_PREFIX "x"
  941. # endif
  942. #endif
  943. #if !defined PRIXPTR
  944. # ifdef UINTPTR_MAX
  945. # define PRIXPTR __PRIPTR_PREFIX "X"
  946. # endif
  947. #endif
  948. #if !defined SCNd8
  949. # ifdef INT8_MAX
  950. # define SCNd8 "hhd"
  951. # endif
  952. #endif
  953. #if !defined SCNi8
  954. # ifdef INT8_MAX
  955. # define SCNi8 "hhi"
  956. # endif
  957. #endif
  958. #if !defined SCNo8
  959. # ifdef UINT8_MAX
  960. # define SCNo8 "hho"
  961. # endif
  962. #endif
  963. #if !defined SCNu8
  964. # ifdef UINT8_MAX
  965. # define SCNu8 "hhu"
  966. # endif
  967. #endif
  968. #if !defined SCNx8
  969. # ifdef UINT8_MAX
  970. # define SCNx8 "hhx"
  971. # endif
  972. #endif
  973. #if !defined SCNd16
  974. # ifdef INT16_MAX
  975. # define SCNd16 "hd"
  976. # endif
  977. #endif
  978. #if !defined SCNi16
  979. # ifdef INT16_MAX
  980. # define SCNi16 "hi"
  981. # endif
  982. #endif
  983. #if !defined SCNo16
  984. # ifdef UINT16_MAX
  985. # define SCNo16 "ho"
  986. # endif
  987. #endif
  988. #if !defined SCNu16
  989. # ifdef UINT16_MAX
  990. # define SCNu16 "hu"
  991. # endif
  992. #endif
  993. #if !defined SCNx16
  994. # ifdef UINT16_MAX
  995. # define SCNx16 "hx"
  996. # endif
  997. #endif
  998. #if !defined SCNd32
  999. # ifdef INT32_MAX
  1000. # define SCNd32 "d"
  1001. # endif
  1002. #endif
  1003. #if !defined SCNi32
  1004. # ifdef INT32_MAX
  1005. # define SCNi32 "i"
  1006. # endif
  1007. #endif
  1008. #if !defined SCNo32
  1009. # ifdef UINT32_MAX
  1010. # define SCNo32 "o"
  1011. # endif
  1012. #endif
  1013. #if !defined SCNu32
  1014. # ifdef UINT32_MAX
  1015. # define SCNu32 "u"
  1016. # endif
  1017. #endif
  1018. #if !defined SCNx32
  1019. # ifdef UINT32_MAX
  1020. # define SCNx32 "x"
  1021. # endif
  1022. #endif
  1023. #ifdef INT64_MAX
  1024. # if (0 ? defined _LP64 : defined _LP64)
  1025. # define _SCN64_PREFIX "l"
  1026. # elif defined _MSC_VER || defined __MINGW32__
  1027. # define _SCN64_PREFIX "I64"
  1028. # elif LONG_MAX >> 30 == 1
  1029. # define _SCN64_PREFIX _LONG_LONG_FORMAT_PREFIX
  1030. # endif
  1031. # if !defined SCNd64
  1032. # define SCNd64 _SCN64_PREFIX "d"
  1033. # endif
  1034. # if !defined SCNi64
  1035. # define SCNi64 _SCN64_PREFIX "i"
  1036. # endif
  1037. #endif
  1038. #ifdef UINT64_MAX
  1039. # if (0 ? defined _LP64 : defined _LP64)
  1040. # define _SCNu64_PREFIX "l"
  1041. # elif defined _MSC_VER || defined __MINGW32__
  1042. # define _SCNu64_PREFIX "I64"
  1043. # elif ULONG_MAX >> 31 == 1
  1044. # define _SCNu64_PREFIX _LONG_LONG_FORMAT_PREFIX
  1045. # endif
  1046. # if !defined SCNo64
  1047. # define SCNo64 _SCNu64_PREFIX "o"
  1048. # endif
  1049. # if !defined SCNu64
  1050. # define SCNu64 _SCNu64_PREFIX "u"
  1051. # endif
  1052. # if !defined SCNx64
  1053. # define SCNx64 _SCNu64_PREFIX "x"
  1054. # endif
  1055. #endif
  1056. #if !defined SCNdLEAST8
  1057. # define SCNdLEAST8 "hhd"
  1058. #endif
  1059. #if !defined SCNiLEAST8
  1060. # define SCNiLEAST8 "hhi"
  1061. #endif
  1062. #if !defined SCNoLEAST8
  1063. # define SCNoLEAST8 "hho"
  1064. #endif
  1065. #if !defined SCNuLEAST8
  1066. # define SCNuLEAST8 "hhu"
  1067. #endif
  1068. #if !defined SCNxLEAST8
  1069. # define SCNxLEAST8 "hhx"
  1070. #endif
  1071. #if !defined SCNdLEAST16
  1072. # define SCNdLEAST16 "hd"
  1073. #endif
  1074. #if !defined SCNiLEAST16
  1075. # define SCNiLEAST16 "hi"
  1076. #endif
  1077. #if !defined SCNoLEAST16
  1078. # define SCNoLEAST16 "ho"
  1079. #endif
  1080. #if !defined SCNuLEAST16
  1081. # define SCNuLEAST16 "hu"
  1082. #endif
  1083. #if !defined SCNxLEAST16
  1084. # define SCNxLEAST16 "hx"
  1085. #endif
  1086. #if !defined SCNdLEAST32
  1087. # define SCNdLEAST32 "d"
  1088. #endif
  1089. #if !defined SCNiLEAST32
  1090. # define SCNiLEAST32 "i"
  1091. #endif
  1092. #if !defined SCNoLEAST32
  1093. # define SCNoLEAST32 "o"
  1094. #endif
  1095. #if !defined SCNuLEAST32
  1096. # define SCNuLEAST32 "u"
  1097. #endif
  1098. #if !defined SCNxLEAST32
  1099. # define SCNxLEAST32 "x"
  1100. #endif
  1101. #ifdef INT64_MAX
  1102. # if !defined SCNdLEAST64
  1103. # define SCNdLEAST64 SCNd64
  1104. # endif
  1105. # if !defined SCNiLEAST64
  1106. # define SCNiLEAST64 SCNi64
  1107. # endif
  1108. #endif
  1109. #ifdef UINT64_MAX
  1110. # if !defined SCNoLEAST64
  1111. # define SCNoLEAST64 SCNo64
  1112. # endif
  1113. # if !defined SCNuLEAST64
  1114. # define SCNuLEAST64 SCNu64
  1115. # endif
  1116. # if !defined SCNxLEAST64
  1117. # define SCNxLEAST64 SCNx64
  1118. # endif
  1119. #endif
  1120. #if !defined SCNdFAST8
  1121. # if INT_FAST8_MAX > INT32_MAX
  1122. # define SCNdFAST8 SCNd64
  1123. # elif INT_FAST8_MAX == 0x7fff
  1124. # define SCNdFAST8 "hd"
  1125. # elif INT_FAST8_MAX == 0x7f
  1126. # define SCNdFAST8 "hhd"
  1127. # else
  1128. # define SCNdFAST8 "d"
  1129. # endif
  1130. #endif
  1131. #if !defined SCNiFAST8
  1132. # if INT_FAST8_MAX > INT32_MAX
  1133. # define SCNiFAST8 SCNi64
  1134. # elif INT_FAST8_MAX == 0x7fff
  1135. # define SCNiFAST8 "hi"
  1136. # elif INT_FAST8_MAX == 0x7f
  1137. # define SCNiFAST8 "hhi"
  1138. # else
  1139. # define SCNiFAST8 "i"
  1140. # endif
  1141. #endif
  1142. #if !defined SCNoFAST8
  1143. # if UINT_FAST8_MAX > UINT32_MAX
  1144. # define SCNoFAST8 SCNo64
  1145. # elif UINT_FAST8_MAX == 0xffff
  1146. # define SCNoFAST8 "ho"
  1147. # elif UINT_FAST8_MAX == 0xff
  1148. # define SCNoFAST8 "hho"
  1149. # else
  1150. # define SCNoFAST8 "o"
  1151. # endif
  1152. #endif
  1153. #if !defined SCNuFAST8
  1154. # if UINT_FAST8_MAX > UINT32_MAX
  1155. # define SCNuFAST8 SCNu64
  1156. # elif UINT_FAST8_MAX == 0xffff
  1157. # define SCNuFAST8 "hu"
  1158. # elif UINT_FAST8_MAX == 0xff
  1159. # define SCNuFAST8 "hhu"
  1160. # else
  1161. # define SCNuFAST8 "u"
  1162. # endif
  1163. #endif
  1164. #if !defined SCNxFAST8
  1165. # if UINT_FAST8_MAX > UINT32_MAX
  1166. # define SCNxFAST8 SCNx64
  1167. # elif UINT_FAST8_MAX == 0xffff
  1168. # define SCNxFAST8 "hx"
  1169. # elif UINT_FAST8_MAX == 0xff
  1170. # define SCNxFAST8 "hhx"
  1171. # else
  1172. # define SCNxFAST8 "x"
  1173. # endif
  1174. #endif
  1175. #if !defined SCNdFAST16
  1176. # if INT_FAST16_MAX > INT32_MAX
  1177. # define SCNdFAST16 SCNd64
  1178. # elif INT_FAST16_MAX == 0x7fff
  1179. # define SCNdFAST16 "hd"
  1180. # else
  1181. # define SCNdFAST16 "d"
  1182. # endif
  1183. #endif
  1184. #if !defined SCNiFAST16
  1185. # if INT_FAST16_MAX > INT32_MAX
  1186. # define SCNiFAST16 SCNi64
  1187. # elif INT_FAST16_MAX == 0x7fff
  1188. # define SCNiFAST16 "hi"
  1189. # else
  1190. # define SCNiFAST16 "i"
  1191. # endif
  1192. #endif
  1193. #if !defined SCNoFAST16
  1194. # if UINT_FAST16_MAX > UINT32_MAX
  1195. # define SCNoFAST16 SCNo64
  1196. # elif UINT_FAST16_MAX == 0xffff
  1197. # define SCNoFAST16 "ho"
  1198. # else
  1199. # define SCNoFAST16 "o"
  1200. # endif
  1201. #endif
  1202. #if !defined SCNuFAST16
  1203. # if UINT_FAST16_MAX > UINT32_MAX
  1204. # define SCNuFAST16 SCNu64
  1205. # elif UINT_FAST16_MAX == 0xffff
  1206. # define SCNuFAST16 "hu"
  1207. # else
  1208. # define SCNuFAST16 "u"
  1209. # endif
  1210. #endif
  1211. #if !defined SCNxFAST16
  1212. # if UINT_FAST16_MAX > UINT32_MAX
  1213. # define SCNxFAST16 SCNx64
  1214. # elif UINT_FAST16_MAX == 0xffff
  1215. # define SCNxFAST16 "hx"
  1216. # else
  1217. # define SCNxFAST16 "x"
  1218. # endif
  1219. #endif
  1220. #if !defined SCNdFAST32
  1221. # if INT_FAST32_MAX > INT32_MAX
  1222. # define SCNdFAST32 SCNd64
  1223. # else
  1224. # define SCNdFAST32 "d"
  1225. # endif
  1226. #endif
  1227. #if !defined SCNiFAST32
  1228. # if INT_FAST32_MAX > INT32_MAX
  1229. # define SCNiFAST32 SCNi64
  1230. # else
  1231. # define SCNiFAST32 "i"
  1232. # endif
  1233. #endif
  1234. #if !defined SCNoFAST32
  1235. # if UINT_FAST32_MAX > UINT32_MAX
  1236. # define SCNoFAST32 SCNo64
  1237. # else
  1238. # define SCNoFAST32 "o"
  1239. # endif
  1240. #endif
  1241. #if !defined SCNuFAST32
  1242. # if UINT_FAST32_MAX > UINT32_MAX
  1243. # define SCNuFAST32 SCNu64
  1244. # else
  1245. # define SCNuFAST32 "u"
  1246. # endif
  1247. #endif
  1248. #if !defined SCNxFAST32
  1249. # if UINT_FAST32_MAX > UINT32_MAX
  1250. # define SCNxFAST32 SCNx64
  1251. # else
  1252. # define SCNxFAST32 "x"
  1253. # endif
  1254. #endif
  1255. #ifdef INT64_MAX
  1256. # if !defined SCNdFAST64
  1257. # define SCNdFAST64 SCNd64
  1258. # endif
  1259. # if !defined SCNiFAST64
  1260. # define SCNiFAST64 SCNi64
  1261. # endif
  1262. #endif
  1263. #ifdef UINT64_MAX
  1264. # if !defined SCNoFAST64
  1265. # define SCNoFAST64 SCNo64
  1266. # endif
  1267. # if !defined SCNuFAST64
  1268. # define SCNuFAST64 SCNu64
  1269. # endif
  1270. # if !defined SCNxFAST64
  1271. # define SCNxFAST64 SCNx64
  1272. # endif
  1273. #endif
  1274. #if !defined SCNdMAX
  1275. # if 1
  1276. # define SCNdMAX SCNd64
  1277. # else
  1278. # define SCNdMAX "ld"
  1279. # endif
  1280. #endif
  1281. #if !defined SCNiMAX
  1282. # if 1
  1283. # define SCNiMAX SCNi64
  1284. # else
  1285. # define SCNiMAX "li"
  1286. # endif
  1287. #endif
  1288. #if !defined SCNoMAX
  1289. # if 1
  1290. # define SCNoMAX SCNo64
  1291. # else
  1292. # define SCNoMAX "lo"
  1293. # endif
  1294. #endif
  1295. #if !defined SCNuMAX
  1296. # if 1
  1297. # define SCNuMAX SCNu64
  1298. # else
  1299. # define SCNuMAX "lu"
  1300. # endif
  1301. #endif
  1302. #if !defined SCNxMAX
  1303. # if 1
  1304. # define SCNxMAX SCNx64
  1305. # else
  1306. # define SCNxMAX "lx"
  1307. # endif
  1308. #endif
  1309. #if !defined SCNdPTR
  1310. # ifdef INTPTR_MAX
  1311. # define SCNdPTR __PRIPTR_PREFIX "d"
  1312. # endif
  1313. #endif
  1314. #if !defined SCNiPTR
  1315. # ifdef INTPTR_MAX
  1316. # define SCNiPTR __PRIPTR_PREFIX "i"
  1317. # endif
  1318. #endif
  1319. #if !defined SCNoPTR
  1320. # ifdef UINTPTR_MAX
  1321. # define SCNoPTR __PRIPTR_PREFIX "o"
  1322. # endif
  1323. #endif
  1324. #if !defined SCNuPTR
  1325. # ifdef UINTPTR_MAX
  1326. # define SCNuPTR __PRIPTR_PREFIX "u"
  1327. # endif
  1328. #endif
  1329. #if !defined SCNxPTR
  1330. # ifdef UINTPTR_MAX
  1331. # define SCNxPTR __PRIPTR_PREFIX "x"
  1332. # endif
  1333. #endif
  1334. /* 7.8.2 Functions for greatest-width integer types */
  1335. #ifdef __cplusplus
  1336. extern "C" {
  1337. #endif
  1338. #if 0
  1339. # if !1
  1340. extern intmax_t imaxabs (intmax_t);
  1341. # endif
  1342. #elif defined GNULIB_POSIXCHECK
  1343. # undef imaxabs
  1344. # if HAVE_RAW_DECL_IMAXABS
  1345. _GL_WARN_ON_USE (imaxabs, "imaxabs is unportable - "
  1346. "use gnulib module imaxabs for portability");
  1347. # endif
  1348. #endif
  1349. #if 0
  1350. # if !1
  1351. # if !GNULIB_defined_imaxdiv_t
  1352. typedef struct { intmax_t quot; intmax_t rem; } imaxdiv_t;
  1353. # define GNULIB_defined_imaxdiv_t 1
  1354. # endif
  1355. # endif
  1356. # if !1
  1357. extern imaxdiv_t imaxdiv (intmax_t, intmax_t);
  1358. # endif
  1359. #elif defined GNULIB_POSIXCHECK
  1360. # undef imaxdiv
  1361. # if HAVE_RAW_DECL_IMAXDIV
  1362. _GL_WARN_ON_USE (imaxdiv, "imaxdiv is unportable - "
  1363. "use gnulib module imaxdiv for portability");
  1364. # endif
  1365. #endif
  1366. #if 0
  1367. # if 0
  1368. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  1369. # undef strtoimax
  1370. # define strtoimax rpl_strtoimax
  1371. # endif
  1372. _GL_FUNCDECL_RPL (strtoimax, intmax_t,
  1373. (const char *restrict, char **restrict, int)
  1374. _GL_ARG_NONNULL ((1)));
  1375. _GL_CXXALIAS_RPL (strtoimax, intmax_t,
  1376. (const char *restrict, char **restrict, int));
  1377. # else
  1378. # if !1
  1379. # undef strtoimax
  1380. _GL_FUNCDECL_SYS (strtoimax, intmax_t,
  1381. (const char *restrict, char **restrict, int)
  1382. _GL_ARG_NONNULL ((1)));
  1383. # endif
  1384. _GL_CXXALIAS_SYS (strtoimax, intmax_t,
  1385. (const char *restrict, char **restrict, int));
  1386. # endif
  1387. _GL_CXXALIASWARN (strtoimax);
  1388. #elif defined GNULIB_POSIXCHECK
  1389. # undef strtoimax
  1390. # if HAVE_RAW_DECL_STRTOIMAX
  1391. _GL_WARN_ON_USE (strtoimax, "strtoimax is unportable - "
  1392. "use gnulib module strtoimax for portability");
  1393. # endif
  1394. #endif
  1395. #if 0
  1396. # if 0
  1397. # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
  1398. # undef strtoumax
  1399. # define strtoumax rpl_strtoumax
  1400. # endif
  1401. _GL_FUNCDECL_RPL (strtoumax, uintmax_t,
  1402. (const char *restrict, char **restrict, int)
  1403. _GL_ARG_NONNULL ((1)));
  1404. _GL_CXXALIAS_RPL (strtoumax, uintmax_t,
  1405. (const char *restrict, char **restrict, int));
  1406. # else
  1407. # if !1
  1408. # undef strtoumax
  1409. _GL_FUNCDECL_SYS (strtoumax, uintmax_t,
  1410. (const char *restrict, char **restrict, int)
  1411. _GL_ARG_NONNULL ((1)));
  1412. # endif
  1413. _GL_CXXALIAS_SYS (strtoumax, uintmax_t,
  1414. (const char *restrict, char **restrict, int));
  1415. # endif
  1416. _GL_CXXALIASWARN (strtoumax);
  1417. #elif defined GNULIB_POSIXCHECK
  1418. # undef strtoumax
  1419. # if HAVE_RAW_DECL_STRTOUMAX
  1420. _GL_WARN_ON_USE (strtoumax, "strtoumax is unportable - "
  1421. "use gnulib module strtoumax for portability");
  1422. # endif
  1423. #endif
  1424. /* Don't bother defining or declaring wcstoimax and wcstoumax, since
  1425. wide-character functions like this are hardly ever useful. */
  1426. #ifdef __cplusplus
  1427. }
  1428. #endif
  1429. #endif /* !defined INTTYPES_H && !defined _GL_JUST_INCLUDE_SYSTEM_INTTYPES_H */