1 /* Copyright (C) 2010-2020 The RetroArch team
3 * ---------------------------------------------------------------------------------------
4 * The following license statement only applies to this file (retro_common_api.h).
5 * ---------------------------------------------------------------------------------------
7 * Permission is hereby granted, free of charge,
8 * to any person obtaining a copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation the rights to
10 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
11 * and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
16 * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
19 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 #ifndef _LIBRETRO_COMMON_RETRO_COMMON_API_H
24 #define _LIBRETRO_COMMON_RETRO_COMMON_API_H
27 This file is designed to normalize the libretro-common compiling environment
28 for public API headers. This should be leaner than a normal compiling environment,
29 since it gets #included into other project's sources.
32 /* ------------------------------------ */
35 Ordinarily we want to put #ifdef __cplusplus extern "C" in C library
36 headers to enable them to get used by c++ sources.
37 However, we want to support building this library as C++ as well, so a
38 special technique is called for.
41 #define RETRO_BEGIN_DECLS
42 #define RETRO_END_DECLS
47 /* build wants everything to be built as c++, so no extern "C" */
49 #undef RETRO_BEGIN_DECLS
50 #undef RETRO_END_DECLS
51 #define RETRO_BEGIN_DECLS extern "C" {
52 #define RETRO_END_DECLS }
57 /* header is included by a C source file, so no extern "C" */
62 IMO, this non-standard ssize_t should not be used.
63 However, it's a good example of how to handle something like this.
69 typedef __int64 ssize_t;
74 #elif defined(__MACH__)
75 #include <sys/types.h>
89 /* C++11 says this one isn't needed, but apparently (some versions of) mingw require it anyways */
90 /* https://stackoverflow.com/questions/8132399/how-to-printf-uint64-t-fails-with-spurious-trailing-in-format */
91 /* https://github.com/libretro/RetroArch/issues/6009 */
92 #ifndef __STDC_FORMAT_MACROS
93 #define __STDC_FORMAT_MACROS 1
98 #error "inttypes.h is being screwy"
100 #define STRING_REP_INT64 "%" PRId64
101 #define STRING_REP_UINT64 "%" PRIu64
102 #define STRING_REP_USIZE "%" PRIuPTR
105 I would like to see retro_inline.h moved in here; possibly boolean too.
107 rationale: these are used in public APIs, and it is easier to find problems
108 and write code that works the first time portably when theyre included uniformly
109 than to do the analysis from scratch each time you think you need it, for each feature.
111 Moreover it helps force you to make hard decisions: if you EVER bring in boolean.h,
112 then you should pay the price everywhere, so you can see how much grief it will cause.
114 Of course, another school of thought is that you should do as little damage as possible
115 in as few places as possible...
118 /* _LIBRETRO_COMMON_RETRO_COMMON_API_H */