1 //
2 // corecrt_stdio_config.h
3 //
4 //      Copyright (c) Microsoft Corporation. All rights reserved.
5 //
6 // Per-module <stdio.h> configuration.
7 //
8 #pragma once
9 
10 #include <corecrt.h>
11 
12 #pragma warning(push)
13 #pragma warning(disable: _UCRT_DISABLED_WARNINGS)
14 _UCRT_DISABLE_CLANG_WARNINGS
15 
16 _CRT_BEGIN_C_HEADER
17 
18 #if !defined _NO_CRT_STDIO_INLINE && !_CRT_FUNCTIONS_REQUIRED
19     #define _NO_CRT_STDIO_INLINE
20 #endif
21 
22 #if defined _NO_CRT_STDIO_INLINE
23     #undef _CRT_STDIO_INLINE
24     #define _CRT_STDIO_INLINE
25 #elif !defined _CRT_STDIO_INLINE
26     #define _CRT_STDIO_INLINE __inline
27 #endif
28 
29 #if !defined RC_INVOKED // RC has no target architecture
30     #if defined _M_IX86
31         #define _CRT_INTERNAL_STDIO_SYMBOL_PREFIX "_"
32     #elif defined _M_X64 || defined _M_ARM || defined _M_ARM64
33         #define _CRT_INTERNAL_STDIO_SYMBOL_PREFIX ""
34     #else
35         #error Unsupported architecture
36     #endif
37 #endif
38 
39 
40 
41 // Predefine _CRT_STDIO_ISO_WIDE_SPECIFIERS to use ISO-conforming behavior for
42 // the wide string printf and scanf functions (%s, %c, and %[] specifiers).
43 //
44 // Predefine _CRT_STDIO_LEGACY_WIDE_SPECIFIERS to use VC++ 2013 and earlier behavior for
45 // the wide string printf and scanf functions (%s, %c, and %[] specifiers).
46 //
47 // Predefine _CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS when building code that does
48 // not use these format specifiers without a length modifier and thus can be
49 // used with either the legacy (default) or the conforming mode.  (This option
50 // is intended for use by static libraries).
51 #if !defined RC_INVOKED // _CRT_STDIO_LEGACY_WIDE_SPECIFIERS et al. are too long for rc
52     #if defined _CRT_STDIO_ISO_WIDE_SPECIFIERS
53         #if defined _CRT_STDIO_LEGACY_WIDE_SPECIFIERS
54             #error _CRT_STDIO_ISO_WIDE_SPECIFIERS and _CRT_STDIO_LEGACY_WIDE_SPECIFIERS cannot be defined together.
55         #endif
56 
57         #if !defined _M_CEE_PURE
58             #pragma comment(lib, "iso_stdio_wide_specifiers")
59             #pragma comment(linker, "/include:" _CRT_INTERNAL_STDIO_SYMBOL_PREFIX "__PLEASE_LINK_WITH_iso_stdio_wide_specifiers.lib")
60         #endif
61     #elif defined _CRT_STDIO_LEGACY_WIDE_SPECIFIERS
62         #if !defined _M_CEE_PURE
63             #pragma comment(lib, "legacy_stdio_wide_specifiers")
64             #pragma comment(linker, "/include:" _CRT_INTERNAL_STDIO_SYMBOL_PREFIX "__PLEASE_LINK_WITH_legacy_stdio_wide_specifiers.lib")
65         #endif
66     #endif
67 
68     #if defined __cplusplus && !defined _CRT_STDIO_ARBITRARY_WIDE_SPECIFIERS
69         #ifdef _CRT_STDIO_ISO_WIDE_SPECIFIERS
70             #pragma detect_mismatch("_CRT_STDIO_ISO_WIDE_SPECIFIERS", "1")
71         #else
72             #pragma detect_mismatch("_CRT_STDIO_ISO_WIDE_SPECIFIERS", "0")
73         #endif
74     #endif
75 #endif
76 
77 // If we're compiling mixed managed code, make sure these inline functions are
78 // compiled as native to ensure that there is only one instance of each of the
79 // function-local static variables.
80 #if defined _M_CEE && !defined _M_CEE_PURE
81     #pragma managed(push, off)
82 #endif
83 
84 #if _CRT_FUNCTIONS_REQUIRED
85     // This function must not be inlined into callers to avoid ODR violations.  The
86     // static local variable has different names in C and in C++ translation units.
87     _Check_return_ _Ret_notnull_
88     _CRT_INLINE_PURE_SECURITYCRITICAL_ATTRIBUTE
__local_stdio_printf_options(void)89     __declspec(noinline) __inline unsigned __int64* __CRTDECL __local_stdio_printf_options(void)
90     {
91         static unsigned __int64 _OptionsStorage;
92         return &_OptionsStorage;
93     }
94 
95     // This function must not be inlined into callers to avoid ODR violations.  The
96     // static local variable has different names in C and in C++ translation units.
97     _Check_return_ _Ret_notnull_
98     _CRT_INLINE_PURE_SECURITYCRITICAL_ATTRIBUTE
__local_stdio_scanf_options(void)99     __declspec(noinline) __inline unsigned __int64* __CRTDECL __local_stdio_scanf_options(void)
100     {
101         static unsigned __int64 _OptionsStorage;
102         return &_OptionsStorage;
103     }
104 #endif
105 
106 #if defined _M_CEE && !defined _M_CEE_PURE
107     #pragma managed(pop)
108 #endif
109 
110 #define _CRT_INTERNAL_LOCAL_PRINTF_OPTIONS (*__local_stdio_printf_options())
111 #define _CRT_INTERNAL_LOCAL_SCANF_OPTIONS  (*__local_stdio_scanf_options ())
112 
113 
114 
115 #define _CRT_INTERNAL_PRINTF_LEGACY_VSPRINTF_NULL_TERMINATION (1ULL << 0)
116 #define _CRT_INTERNAL_PRINTF_STANDARD_SNPRINTF_BEHAVIOR       (1ULL << 1)
117 #define _CRT_INTERNAL_PRINTF_LEGACY_WIDE_SPECIFIERS           (1ULL << 2)
118 #define _CRT_INTERNAL_PRINTF_LEGACY_MSVCRT_COMPATIBILITY      (1ULL << 3)
119 #define _CRT_INTERNAL_PRINTF_LEGACY_THREE_DIGIT_EXPONENTS     (1ULL << 4)
120 #define _CRT_INTERNAL_PRINTF_STANDARD_ROUNDING                (1ULL << 5)
121 
122 
123 #define _CRT_INTERNAL_SCANF_SECURECRT                   (1ULL << 0)
124 #define _CRT_INTERNAL_SCANF_LEGACY_WIDE_SPECIFIERS      (1ULL << 1)
125 #define _CRT_INTERNAL_SCANF_LEGACY_MSVCRT_COMPATIBILITY (1ULL << 2)
126 
127 
128 
129 _CRT_END_C_HEADER
130 _UCRT_RESTORE_CLANG_WARNINGS
131 #pragma warning(pop) // _UCRT_DISABLED_WARNINGS
132