xref: /freebsd/share/man/man9/cdefs.9 (revision f7331f4ec87eef7ff9e2aa0109fcee06d71edff2)
14122295aSWarner Losh.\"-
24122295aSWarner Losh.\" Copyright (c) 2024 M. Warner Losh <imp@FreeBSD.org>
34122295aSWarner Losh.\"
44122295aSWarner Losh.\" SPDX-License-Identifier: BSD-2-Clause
54122295aSWarner Losh.\"
6*f7331f4eSWarner Losh.Dd July 18, 2024
74122295aSWarner Losh.Dt CDEFS 9
84122295aSWarner Losh.Os
94122295aSWarner Losh.Sh NAME
104122295aSWarner Losh.Nm cdefs
114122295aSWarner Losh.Nd compiler portability macro definitions
124122295aSWarner Losh.Sh DESCRIPTION
134122295aSWarner Losh.In sys/cdefs.h
144122295aSWarner Loshdefines macros for compiler, C language standard portability, POSIX standards
154122295aSWarner Loshcompliance and symbol visibility.
164122295aSWarner LoshIt defines programming interfaces for the system header files to adopt to the
174122295aSWarner Loshmany environments
184122295aSWarner Losh.Fx
194122295aSWarner Loshsupports compilation for.
204122295aSWarner LoshIt defines convenience macros for the
214122295aSWarner Losh.Fx
224122295aSWarner Loshsources, tailored to the base
234122295aSWarner Loshsystem's needs.
244122295aSWarner Losh.Pp
254122295aSWarner LoshMost of these macros are for use inside the
264122295aSWarner Losh.Fx
274122295aSWarner Loshsources only.
284122295aSWarner LoshThey are not intended as a general portability layer.
294122295aSWarner Losh.Sh Supported Compilers
304122295aSWarner Losh.Bl -tag -offset 2n -width 0
314122295aSWarner Losh.It Compilers supported for building programs on Fx :
324122295aSWarner Losh.Bl -column -offset 0n indent-two
334122295aSWarner Losh.It Sy Compiler Ta Sy Versions
344122295aSWarner Losh.It gcc Ta 9, 10, 11, 12, 13, 14
354122295aSWarner Losh.It clang Ta 10, 11, 12, 13, 14, 15, 16, 17, 18
364122295aSWarner Losh.It TinyC (tcc) Ta 0.9
374122295aSWarner Losh.It pcc Ta 1.1
384122295aSWarner Losh.El
394122295aSWarner Losh.Pp
404122295aSWarner LoshDue to testing constraints, tcc and pcc may not always work.
414122295aSWarner Losh.It Compilers supported for building Fx itself:
424122295aSWarner Losh.Bl -column -offset 0n indent-two
43*f7331f4eSWarner Losh.It Sy Compiler Ta Sy Major Versions Supported
44*f7331f4eSWarner Losh.It gcc Ta 12, 13, 14
45*f7331f4eSWarner Losh.It clang Ta 16, 17, 18
464122295aSWarner Losh.El
47*f7331f4eSWarner Losh.Pp
48*f7331f4eSWarner LoshPlease note: Not every single minor versions of these compilers
49*f7331f4eSWarner Loshwill work or are supported.
504122295aSWarner Losh.Sh Macros and Magic for Programming Environment
514122295aSWarner Losh.Nm
524122295aSWarner Loshdefines (or refrains from defining) a number of macros to increase portability
534122295aSWarner Loshof compiled programs.
544122295aSWarner LoshThese are to allow more advanced language features to appear in header files.
554122295aSWarner LoshThe header files assume a compiler that accepts C prototype function
564122295aSWarner Loshdeclarations.
574122295aSWarner LoshThey also assume that the compiler accepts ANSI C89 keywords for all language
584122295aSWarner Loshdialects.
594122295aSWarner Losh.Ss General Macros
604122295aSWarner LoshGeneral macros that facilitate multiple language environments and language
614122295aSWarner Loshdialects.
624122295aSWarner Losh.Bl -column "---------------"
634122295aSWarner Losh.It Sy Macro Ta Sy Description
644122295aSWarner Losh.It Dv __volatile Ta expands to volatile in C++ and C89 and newer environments,
654122295aSWarner Losh__volatile in pre-ANSI environments that support this extension or nothing
664122295aSWarner Loshotherwise.
674122295aSWarner Losh.It Dv __inline Ta expands to inline in C++ and C89 and newer environments,
684122295aSWarner Losh__inline in pre-ANSI environments that support this extension or nothing
694122295aSWarner Loshotherwise.
704122295aSWarner Losh.It Dv __restrict Ta expands to restrict in C99 and newer environments, or
714122295aSWarner Losh__restrict otherwise.
724122295aSWarner Losh.It Dv __CONCAT Ta used to paste two pre-processor tokens.
734122295aSWarner Losh.It Dv __STRING Ta used to convert the argument to a string.
744122295aSWarner Losh.It Dv __BEGIN_DECLS Ta Start a group of functions.
754122295aSWarner Losh.It Dv __END_DECLS Ta End a group of functions.
764122295aSWarner LoshIn a C environment, these are defined as nothing.
774122295aSWarner LoshIn a C++ environment, these declare the functions to have
784122295aSWarner Losh.Dq C
794122295aSWarner Loshlinkage.
804122295aSWarner Losh.El
814122295aSWarner Losh.Ss Function, Structure and Variable Modifiers
824122295aSWarner Losh.Bl -column "---------------"
834122295aSWarner Losh.It Sy Macro Ta Sy Description
844122295aSWarner Losh.It Sy __weak_symbol Ta Declare the symbol to be a weak symbol
854122295aSWarner Losh.It Sy __dead2 Ta Function will not return
864122295aSWarner Losh.It Sy __pure2 Ta Function has no side effects
874122295aSWarner Losh.It Sy __unused Ta To Variable may be unused (usually arguments), so do not warn about it
884122295aSWarner Losh.It Sy __used Ta Function really is used, so emit it even if it appears unused.
894122295aSWarner Losh.It Sy __packed Ta \&Do not have space between structure elements for natural alignment.
904122295aSWarner LoshUsed when communicating with external protocols.
914122295aSWarner Losh.It Sy __aligned(x) Ta Specify in bytes the minimum alignment for the specified field, structure or variable
924122295aSWarner Losh.It Sy __section(x) Ta Place function or variable in section Fa x
934122295aSWarner Losh.It Sy __writeonly Ta Hint that the variable is only assigned to, but do not warn about it.
944122295aSWarner LoshUseful for macros and other places the eventual use of the result is unknown.
954122295aSWarner Losh.It Sy __alloc_size(x) Ta The function always returns at least the number of
964122295aSWarner Loshbytes determined by argument number Fa x
974122295aSWarner Losh.It Sy __alloc_size2(x,n) Ta  The function always returns an array, whose size
984122295aSWarner Loshis at least the number of bytes determined by argument number Fa x times the
994122295aSWarner Loshnumber of elements specified by argument number Fa n
1004122295aSWarner Losh.It Sy __alloc_align(x) Ta Function either returns a pointer aligned to Fa x bytes
1014122295aSWarner Loshor Dv NULL.
1024122295aSWarner Losh.It Sy __min_size Ta Declare the array to have a certain, minimum size
1034122295aSWarner Losh.It Sy __malloc_like Ta Function behaves like the
1044122295aSWarner Losh.Dq malloc
1054122295aSWarner Loshfamily of functions.
1064122295aSWarner Losh.It Sy __pure Ta Function has no side effects
1074122295aSWarner Losh.It Sy __always_inline Ta Always inline this function when called
1084122295aSWarner Losh.It Sy __fastcall Ta Use the
1094122295aSWarner Losh.Dq fastcall
1104122295aSWarner LoshABI to call and name mangle this function.
1114122295aSWarner Losh.It Sy __result_use_check Ta Warn if function caller does not use it's return value
1124122295aSWarner Losh.It Sy __result_use_or_ignore_check Ta Warn if function caller does not use it's return value.
1134122295aSWarner LoshAllows the value to be explicitly ignored with a (void) cast.
1144122295aSWarner Losh.It Sy __returns_twice Ta Returns multiple times, like
1154122295aSWarner Losh.Xr fork 2
1164122295aSWarner Losh.It Sy __unreachable Ta This code is not reachable at runtime
1174122295aSWarner Losh.It Sy __predict_true(x) Ta Hint to the compiler that
1184122295aSWarner Losh.Fa x
1194122295aSWarner Loshis true most of the time.
1204122295aSWarner LoshShould only be used when performance is improved for a frequently called bit of code.
1214122295aSWarner Losh.It Sy __predict_false(x) Ta Hint to the compiler that
1224122295aSWarner Losh.Fa x
1234122295aSWarner Loshis false most of the time.
1244122295aSWarner LoshShould only be used when performance is improved for a frequently called bit of code.
1254122295aSWarner Losh.It Sy __null_sentinel Ta The varadic function contains a parameter that is
1264122295aSWarner Losha NULL sentinel to mark the end of its arguments.
1274122295aSWarner Losh.It Sy __exported Ta
1284122295aSWarner Losh.It Sy __hidden Ta
1294122295aSWarner Losh.It Sy __printflike(fmtarg,firstvararg) Ta Function is similar to
1304122295aSWarner Losh.Fn printf
1314122295aSWarner Loshwhich specifies the format argument with
1324122295aSWarner Losh.Fa fmtarg
1334122295aSWarner Loshand where the arguments formatted by that format start with the
1344122295aSWarner Losh.Fa firstvararg ,
1354122295aSWarner Loshwith 0 meaning that
1364122295aSWarner Losh.Dv va_arg
1374122295aSWarner Loshis used and cannot be checked.
1384122295aSWarner Losh.It Sy __scanflike(fmtarg,firstvararg) Ta Function is similar to
1394122295aSWarner Losh.Fn scanf
1404122295aSWarner Loshwhich specifies the format argument with
1414122295aSWarner Losh.Fa fmtarg
1424122295aSWarner Loshand where the arguments formatted by that format start with the
1434122295aSWarner Losh.Fa firstvararg ,
1444122295aSWarner Loshwith 0 meaning that
1454122295aSWarner Losh.Dv va_arg
1464122295aSWarner Loshis used and cannot be checked.
1474122295aSWarner Losh.It Sy __format_arg(f) Ta Specifies that arg
1484122295aSWarner Losh.Fa f
1494122295aSWarner Loshcontains a string that will be passed to a function like
1504122295aSWarner Losh.Fn printf
1514122295aSWarner Loshor
1524122295aSWarner Losh.Fa scanf
1534122295aSWarner Loshafter being translated in some way.
1544122295aSWarner Losh.It Sy __strfmonlike(fmtarg,firstvararg) Ta Function is similar to
1554122295aSWarner Losh.Fn scanf
1564122295aSWarner Loshwhich specifies the format argument with
1574122295aSWarner Losh.Fa fmtarg
1584122295aSWarner Loshand where the arguments formatted by that format start with the
1594122295aSWarner Losh.Fa firstvararg ,
1604122295aSWarner Loshwith 0 meaning that
1614122295aSWarner Losh.Dv va_arg
1624122295aSWarner Loshis used and cannot be checked.
1634122295aSWarner Losh.It Sy __strtimelike(fmtarg,firstvararg) Ta Function is similar to
1644122295aSWarner Losh.Fn scanf
1654122295aSWarner Loshwhich specifies the format argument with
1664122295aSWarner Losh.Fa fmtarg
1674122295aSWarner Loshand where the arguments formatted by that format start with the
1684122295aSWarner Losh.Fa firstvararg ,
1694122295aSWarner Loshwith 0 meaning that
1704122295aSWarner Losh.Dv va_arg
1714122295aSWarner Loshis used and cannot be checked.
1724122295aSWarner Losh.It Sy __printf0like(fmtarg,firstvararg) Ta Exactly the same
1734122295aSWarner Loshas
1744122295aSWarner Losh.Sy __printflike
1754122295aSWarner Loshexcept
1764122295aSWarner Losh.Fa fmtarg
1774122295aSWarner Loshmay be
1784122295aSWarner Losh.Dv NULL.
1794122295aSWarner Losh.It Sy __strong_reference(sym,aliassym) Ta
1804122295aSWarner Losh.It Sy __weak_reference(sym,alias) Ta
1814122295aSWarner Losh.It Sy __warn_references(sym,msg) Ta
1824122295aSWarner Losh.It Sy __sym_compat(sym,impl,verid) Ta
1834122295aSWarner Losh.It Sy __sym_default(sym,impl,verid) Ta
1844122295aSWarner Losh.It Sy __GLOBAL(sym) Ta
1854122295aSWarner Losh.It Sy __WEAK(sym) Ta
1864122295aSWarner Losh.It Sy __DECONST(type,var) Ta
1874122295aSWarner Losh.It Sy __DEVOLATILE(type,var) Ta
1884122295aSWarner Losh.It Sy __DEQUALIFY(type,var) Ta
1894122295aSWarner Losh.It Sy __RENAME(x) Ta
1904122295aSWarner Losh.It Sy __arg_type_tag Ta
1914122295aSWarner Losh.It Sy __datatype_type_tag Ta
1924122295aSWarner Losh.It Sy __align_up(x,y) Ta
1934122295aSWarner Losh.It Sy __align_down(x,y) Ta
1944122295aSWarner Losh.It Sy __is_aligned(x,y) Ta
1954122295aSWarner Losh.El
1964122295aSWarner Losh.Ss Locking and Debugging Macros
1974122295aSWarner LoshMacros for lock annotation and debugging, as well as some general debugging
1984122295aSWarner Loshmacros for address sanitizers.
1994122295aSWarner Losh.Bl -column "---------------"
2004122295aSWarner Losh.It Sy __lock_annotate(x) Ta
2014122295aSWarner Losh.It Sy __lockable Ta
2024122295aSWarner Losh.It Sy __locks_exclusive Ta
2034122295aSWarner Losh.It Sy __locks_shared Ta
2044122295aSWarner Losh.It Sy __trylocks_exclusive Ta
2054122295aSWarner Losh.It Sy __trylocks_shared Ta
2064122295aSWarner Losh.It Sy __unlocks Ta
2074122295aSWarner Losh.It Sy __asserts_exclusive Ta
2084122295aSWarner Losh.It Sy __asserts_shared Ta
2094122295aSWarner Losh.It Sy __requires_exclusive Ta
2104122295aSWarner Losh.It Sy __requires_shared Ta
2114122295aSWarner Losh.It Sy __requires_unlocked Ta
2124122295aSWarner Losh.It Sy __no_lock_analysis Ta
2134122295aSWarner Losh.It Sy __nosanitizeaddress Ta
2144122295aSWarner Losh.It Sy __nosanitizememory Ta
2154122295aSWarner Losh.It Sy __nosanitizethread Ta
2164122295aSWarner Losh.It Sy __nostackprotector Ta
2174122295aSWarner Losh.It Sy __guarded_by(x) Ta
2184122295aSWarner Losh.It Sy __pt_guarded_by(x) Ta
2194122295aSWarner Losh.El
2204122295aSWarner Losh.Ss Emulated Keywords
2214122295aSWarner LoshAs C evolves, many of the old macros we once used have been incorporated into
2224122295aSWarner Loshthe standard language.
2234122295aSWarner LoshAs this happens, we add support for these keywords as macros for older
2244122295aSWarner Loshcompilation environments.
2254122295aSWarner LoshSometimes this results in a nop in the older environment.
2264122295aSWarner Losh.Bl -column "---------------"
2274122295aSWarner Losh.It Sy Keyword Ta Sy Description
2284122295aSWarner Losh.It Sy _Alignas(x) Ta
2294122295aSWarner Losh.It Sy _Alignof(x) Ta
2304122295aSWarner Losh.It Sy _Noreturn Ta Expands to
2314122295aSWarner Losh.Dq [[noreturn]]
2324122295aSWarner Loshin C++-11 and newer compilation environments, otherwise
2334122295aSWarner Losh.Dq __dead2
2344122295aSWarner Losh.It Sy _Static_assert(x, y) Ta Compile time assertion that
2354122295aSWarner Losh.Fa x
2364122295aSWarner Loshis true, otherwise emit
2374122295aSWarner Losh.Fa y
2384122295aSWarner Loshas the error message.
2394122295aSWarner Losh.It Sy _Thread_local Ta Designate variable as thread local storage
2404122295aSWarner Losh.It Sy __generic Ta implement _Generic-like features which aren't entirely possible to emulate the _Generic keyword
2414122295aSWarner Losh.It Sy __noexcept Ta to emulate the C++11 argument-less noexcept form
2424122295aSWarner Losh.It Sy __noexcept_if Ta to emulate the C++11 conditional noexcept form
2434122295aSWarner Losh.It Sy _Nonnull Ta
2444122295aSWarner Losh.It Sy _Nullable Ta
2454122295aSWarner Losh.It Sy _Null_unspecified Ta
2464122295aSWarner Losh.El
2474122295aSWarner Losh.Ss Support Macros
2484122295aSWarner LoshThe following macros are defined, or have specific values, to denote certain
2494122295aSWarner Loshthings about the build environment.
2504122295aSWarner Losh.Bl -column "---------------"
2514122295aSWarner Losh.It Sy Macro Ta Sy Description
2524122295aSWarner Losh.It Sy __LONG_LONG_SUPPORTED Ta Variables may be declared
2534122295aSWarner Losh.Dq long long .
2544122295aSWarner LoshThis is defined for C99 or newer and C++ environments.
2554122295aSWarner Losh.It Sy __STDC_LIMIT_MACROS Ta
2564122295aSWarner Losh.It Sy __STDC_CONSTANT_MACROS Ta
2574122295aSWarner Losh.El
2584122295aSWarner Losh.Ss Convenience Macros
2594122295aSWarner LoshThese macros make it easier to do a number of things, even though strictly
2604122295aSWarner Loshspeaking the standard places their normal form in another header.
2614122295aSWarner Losh.Bl -column "---------------"
2624122295aSWarner Losh.It Sy Macro Ta Sy Description
2634122295aSWarner Losh.It Sy __offsetof(type,field) Ta
2644122295aSWarner Losh.It Sy __rangeof(type,start,end) Ta
2654122295aSWarner Losh.It Sy __containerof(x,s,m) Ta
2664122295aSWarner Losh.El
2674122295aSWarner Losh.Ss ID Strings
2684122295aSWarner LoshThis section is deprecated, but is kept around because too much contrib software
2694122295aSWarner Loshstill uses these.
2704122295aSWarner Losh.Bl -column "---------------"
2714122295aSWarner Losh.It Sy Macro Ta Sy Description
2724122295aSWarner Losh.It Sy __IDSTRING(name,string) Ta
2734122295aSWarner Losh.It Sy __FBSDID(s) Ta
2744122295aSWarner Losh.It Sy __RCSID(s) Ta
2754122295aSWarner Losh.It Sy __RCSID_SOURCE(s) Ta
2764122295aSWarner Losh.It Sy __SCCSID(s) Ta
2774122295aSWarner Losh.It Sy __COPYRIGHT(s) Ta
2784122295aSWarner Losh.El
2794122295aSWarner Losh.Sh Supported C Environments
2804122295aSWarner Losh.Fx
2814122295aSWarner Loshsupports a number C standard environments.
2824122295aSWarner LoshSelection of the language dialect is a compiler-dependent command line option,
2834122295aSWarner Loshthough it is usually
2844122295aSWarner Losh.Fl cstd=XX
2854122295aSWarner Loshwhere XX is the standard to set for compiling, such as c89 or c23.
2864122295aSWarner Losh.Fx
2874122295aSWarner Loshprovides a number of selection macros to control visibility of symbols.
2884122295aSWarner LoshPlease see the section on Selection Macros for the specifics.
2894122295aSWarner Losh.Pp
2904122295aSWarner Losh.Bl -tag
2914122295aSWarner Losh.It K \*(Am R
2924122295aSWarner LoshPre-ANSI Kernighan and Ritchie C.
2934122295aSWarner LoshSometimes called
2944122295aSWarner Losh.Dq knr
2954122295aSWarner Loshor
2964122295aSWarner Losh.Dq C78
2974122295aSWarner Loshto distinguish it from newer standards.
2984122295aSWarner LoshSupport for this compilation environment is dependent on compilers supporting
2994122295aSWarner Loshthis configuration.
3004122295aSWarner LoshMost of the old forms of C have been deprecated or removed in
3014122295aSWarner LoshISO/IEC 9899:2024 (“ISO C23”).
3024122295aSWarner LoshCompilers make compiling in this mode increasingly difficult and support for it
3034122295aSWarner Loshmay ultimately be removed from the tree.
3044122295aSWarner Losh.It St -ansiC
3054122295aSWarner Losh.Dv __STDC__
3064122295aSWarner Loshis defined, however
3074122295aSWarner Losh.Dv __STDC_VERSION__
3084122295aSWarner Loshis not.
3094122295aSWarner Losh.Pp
3104122295aSWarner LoshStrict environment selected with
3114122295aSWarner Losh.Dv _ANSI_SOURCE .
3124122295aSWarner Losh.It St -isoC-99
3134122295aSWarner Losh.Dv __STDC_VERSION__ = 199901L
3144122295aSWarner Losh.Pp
3154122295aSWarner LoshStrict environment selected with
3164122295aSWarner Losh.Dv _C99_SOURCE .
3174122295aSWarner Losh.It St -isoC-2011
3184122295aSWarner Losh.Dv __STDC_VERSION__ = 201112L
3194122295aSWarner Losh.Pp
3204122295aSWarner LoshStrict environment selected with
3214122295aSWarner Losh.Dv _C11_SOURCE .
3224122295aSWarner Losh.It ISO/IEC 9899:2018 (“ISO C17”)
3234122295aSWarner Losh.Dv __STDC_VERSION__ = 201710L
3244122295aSWarner Losh.Pp
3254122295aSWarner LoshStrict environment selected with
3264122295aSWarner Losh.Dv _C11_SOURCE
3274122295aSWarner Loshsince there are no new C17 only symbols or macros.
3284122295aSWarner Losh.Pp
3294122295aSWarner LoshThis version of the standard did not introduce any new features, only made
3304122295aSWarner Loshminor, technical corrections.
3314122295aSWarner Losh.It ISO/IEC 9899:2024 (“ISO C23”)
3324122295aSWarner Losh.Dv __STDC_VERSION__ = 202311L
3334122295aSWarner LoshStrict environment selected with
3344122295aSWarner Losh.Dv _C23_SOURCE
3354122295aSWarner Loshthough this is not yet implemented.
3364122295aSWarner Losh.El
3374122295aSWarner Losh.Pp
3384122295aSWarner LoshFor more information on C standards, see
3394122295aSWarner Losh.Xr c 7 .
3404122295aSWarner Losh.Ss Programming Environment Selection Macros
3414122295aSWarner LoshDefining the macros outlined below requests that the system header files provide
3424122295aSWarner Loshonly the functions, structures and macros (symbols) defined by the appropriate
3434122295aSWarner Loshstandard, while suppressing all extensions.
3444122295aSWarner LoshHowever, system headers not defined by that standard may define extensions.
3454122295aSWarner Losh.Bl -column "---------------"
3464122295aSWarner Losh.It Sy Macro Ta Sy Environment
3474122295aSWarner Losh.It Dv _POSIX_SOURCE Ta St -p1003.1-88 including St -ansiC
3484122295aSWarner Losh.It Dv _POSIX_C_SOURCE = 1 Ta St -p1003.1-88 including St -ansiC
3494122295aSWarner Losh.It Dv _POSIX_C_SOURCE = 2 Ta St -p1003.1-90 including St -ansiC
3504122295aSWarner Losh.It Dv _POSIX_C_SOURCE = 199309 Ta St -p1003.1b-93 including St -ansiC
3514122295aSWarner Losh.It Dv _POSIX_C_SOURCE = 199506 Ta St -p1003.1c-95 including St -ansiC
3524122295aSWarner Losh.It Dv _POSIX_C_SOURCE = 200112 Ta St -p1003.1-2001 including St -isoC-99
3534122295aSWarner Losh.It Dv _POSIX_C_SOURCE = 200809 Ta St -p1003.1-2008 including St -isoC-99
3544122295aSWarner Losh.It Dv _POSIX_C_SOURCE = 202405 Ta in the future IEEE Std 1003.1-2024 (“POSIX.1”) including ISO/IEC 9899:2024 (“ISO C23”)
3554122295aSWarner Losh.It Dv _XOPEN_SOURCE = 500 Ta St -p1003.1c-95 and XPG extensions to St -susv2 including St -ansiC
3564122295aSWarner Losh.It Dv _XOPEN_SOURCE = 600 Ta St -p1003.1-2001 and XPG extensions to St -susv3 including St -isoC-99
3574122295aSWarner Losh.It Dv _XOPEN_SOURCE = 700 Ta St -p1003.1-2008 and XPG extensions to St -susv4 including St -isoC-99
3584122295aSWarner Losh.It Dv _XOPEN_SOURCE = 800 Ta in the future IEEE Std 1003.1-2024 (“POSIX.1”) and XPG extensions to Version 5 of the Single UNIX Specification (“SUSv5”) including ISO/IEC 9899:2024 (“ISO C23”)
3594122295aSWarner Losh.It Dv _ANSI_SOURCE Ta St -ansiC
3604122295aSWarner Losh.It Dv _C99_SOURCE Ta St -isoC-99
3614122295aSWarner Losh.It Dv _C11_SOURCE Ta St -isoC-2011
3624122295aSWarner Losh.It Dv _C23_SOURCE Ta in the future ISO/IEC 9899:2024 (“ISO C23”)
3634122295aSWarner Losh.It Dv _BSD_SOURCE Ta Everything, including Fx extensions
3644122295aSWarner Losh.El
3654122295aSWarner Losh.Pp
3664122295aSWarner LoshWhen both POSIX and C environments are selected, the POSIX environment selects
3674122295aSWarner Loshwhich C environment is used.
3684122295aSWarner LoshHowever, when C11 dialect is selected with
3694122295aSWarner Losh.St -p1003.1-2008 ,
3704122295aSWarner Loshdefinitions for
3714122295aSWarner Losh.St -isoC-11
3724122295aSWarner Loshare included.
3734122295aSWarner Losh.Ss Header Visibility Macros
3744122295aSWarner LoshThese macros are set by
3754122295aSWarner Losh.Nm
3764122295aSWarner Loshto control the visibility of different standards.
3774122295aSWarner LoshUsers should not use these, but they are documented here for developers.
3784122295aSWarner Losh.Bl -column "---------------"
3794122295aSWarner Losh.It Dv __XSI_VISIBLE Ta Restricts the visibility of XOPEN Single Unix Standard version.
3804122295aSWarner LoshPossible values are 500, 600, 700 or 800, corresponding to Issue 5, 6, 7, or 8
3814122295aSWarner Loshof the Single Unix Standard.
3824122295aSWarner LoshThese are extra functions in addition to the normal POSIX ones.
3834122295aSWarner Losh.It Dv __POSIX_VISIBLE Ta Make symbols associated with certain standards versions visible.
3844122295aSWarner LoshSet to the value assigned to
3854122295aSWarner Losh.Dv _POSIX_C_SOURCE
3864122295aSWarner Loshby convention with 199009 for
3874122295aSWarner Losh.St -p1003.1-88
3884122295aSWarner Loshand 199209
3894122295aSWarner Losh.St -p1003.1-90 .
3904122295aSWarner Losh.It Dv __ISO_C_VISIBLE Ta The C level that's visible.
3914122295aSWarner LoshPossible values include 1990, 1999, and 2011 for
3924122295aSWarner Losh.St -isoC-90 ,
3934122295aSWarner Losh.St -isoC-99
3944122295aSWarner Loshand
3954122295aSWarner Losh.St -isoC-2011
3964122295aSWarner Loshrespectively.
3974122295aSWarner LoshIn the future, 2023 will be used for ISO C2023.
3984122295aSWarner Losh.It Dv __BSD_VISIBLE Ta 1 if the
3994122295aSWarner Losh.Fx
4004122295aSWarner Loshextensions are visible, 0 otherwise.
4014122295aSWarner Losh.It Dv __EXT1_VISIBLE Ta 1 if the
4024122295aSWarner Losh.St -isoC-2011
4034122295aSWarner LoshAppendix K 3.7.4.1
4044122295aSWarner Loshextensions are visible, 0 otherwise.
4054122295aSWarner Losh.Sh HISTORY
4064122295aSWarner Losh.In sys/cdefs.h
4074122295aSWarner Loshfirst appeared in
4084122295aSWarner Losh.Bx 4.3 NET/2 .
409