Banjo API 0.0.1
Multi-purpose C99 API
Loading...
Searching...
No Matches
api.h
Go to the documentation of this file.
1
4
10#pragma once
11
12#include <stddef.h>
13#include <stdint.h>
14
16#define BJ_VERSION_MAJOR(version) (((version) >> 22U) & 0x3FFU)
17
19#define BJ_VERSION_MINOR(version) (((version) >> 12U) & 0x3FFU)
20
22#define BJ_VERSION_PATCH(version) ((version) & 0xFFFU)
23
29#define BJ_MAKE_VERSION(major, minor, patch) \
30 ((((uint32_t)(major)) << 22U) | (((uint32_t)(minor)) << 12U) | ((uint32_t)(patch)))
31
32#define BJ_VERSION_MAJOR_NUMBER 0
33#define BJ_VERSION_MINOR_NUMBER 1
34#define BJ_VERSION_PATCH_NUMBER 0
35
37#define BJ_VERSION BJ_MAKE_VERSION(BJ_VERSION_MAJOR_NUMBER, BJ_VERSION_MINOR_NUMBER, BJ_VERSION_PATCH_NUMBER)
38
40#define BJ_NAME "Banjo"
41
43#if defined(__EMSCRIPTEN__)
44# define BJ_OS_EMSCRIPTEN
45#elif defined(WIN32) || defined(_WIN32) || defined(__WIN32__)
46# define BJ_OS_WINDOWS
47#elif defined(__linux__) || defined(__gnu_linux__)
48# define BJ_OS_LINUX
49#elif __APPLE__
50# define BJ_OS_APPLE
51# include <TargetConditionals.h>
52# if TARGET_OS_IPHONE
53# define BJ_OS_IOS
54# elif TARGET_IPHONE_SIMULATOR
55# define BJ_OS_IOS
56# define BJ_OS_IOS_SIMULATOR
57# elif TARGET_OS_MAC
58# define BJ_OS_MACOS
59# define BJ_OS_UNIX
60# else
61# define BJ_OS_APPLE_UNKNOWN
62# endif
63#else
64# define BJ_OS_UNKNOWN
65#endif
66
67#if defined(__unix__)
68# define BJ_OS_UNIX
69#endif
70
71// Compiler Detection
72#if defined(__EMSCRIPTEN__)
73 #include <emscripten/version.h>
74 #define BJ_COMPILER_EMSCRIPTEN
75 #define BJ_COMPILER_NAME "Emscripten"
76 #define BJ_COMPILER_VERSION __EMSCRIPTEN_major__
77#elif defined(__GNUC__) && !defined(__clang__)
78 #define BJ_COMPILER_GCC
79 #define BJ_COMPILER_NAME "GCC"
80 #define BJ_COMPILER_VERSION __GNUC__
81#elif defined(__clang__)
82 #define BJ_COMPILER_CLANG
83 #define BJ_COMPILER_NAME "Clang"
84 #define BJ_COMPILER_VERSION __clang_major__
85#elif defined(_MSC_VER)
86 #define BJ_COMPILER_MSVC
87 #define BJ_COMPILER_NAME "MSVC"
88 #define BJ_COMPILER_VERSION _MSC_VER
89#elif defined(__MINGW32__)
90 #define BJ_COMPILER_MINGW
91 #define BJ_COMPILER_NAME "MinGW"
92 #define BJ_COMPILER_VERSION 0
93#else
94 #define BJ_COMPILER_UNKNOWN
95 #define BJ_COMPILER_NAME "Unknown"
96 #define BJ_COMPILER_VERSION 0
97#endif
98
99#ifdef NDEBUG
100# define BJ_BUILD_RELEASE
101#else
102# define BJ_BUILD_DEBUG
103#endif
104
105#ifdef BANJO_STATIC
106# define BANJO_EXPORT
107# define BANJO_NO_EXPORT
108#else
109# ifdef _MSC_VER
110# ifndef BANJO_EXPORT
111# ifdef BANJO_EXPORTS
112# define BANJO_EXPORT __declspec(dllexport)
113# else
114# define BANJO_EXPORT __declspec( dllexport )
115# endif
116# endif
117# ifndef BANJO_NO_EXPORT
118# define BANJO_NO_EXPORT
119# endif
120# else
121# ifndef BANJO_EXPORT
122# ifdef BANJO_EXPORTS
123# define BANJO_EXPORT __attribute__((visibility("default")))
124# else
125# define BANJO_EXPORT __attribute__((visibility("default")))
126# endif
127# endif
128# ifndef BANJO_NO_EXPORT
129# define BANJO_NO_EXPORT __attribute__((visibility("hidden")))
130# endif
131# endif
132#endif
133
143typedef uint32_t bj_bool;
144
154#define BJ_FALSE ((bj_bool)0)
155
165#define BJ_TRUE ((bj_bool)1)
166
184
193BANJO_EXPORT const bj_build_info* bj_get_build_info(void);
194
bj_bool feature_emscripten
Compiled with support for Emscripten.
Definition api.h:175
uint32_t version
Built version (BJ_VERSION)
Definition api.h:170
bj_bool feature_win32
Compiled with support for Win32 windows.
Definition api.h:174
bj_bool feature_x11
Compiled with support for Win32 windows.
Definition api.h:176
const char * compiler_name
Compiler C-String name.
Definition api.h:171
const char * p_name
API Name (BJ_NAME)
Definition api.h:169
bj_bool debug
Built with debug information.
Definition api.h:173
bj_bool config_checks_abort
When checks feature is on, a failed check will abort execution.
Definition api.h:179
bj_bool config_pedantic
Banjo runtime will make costly extra checks.
Definition api.h:182
bj_bool feature_mme
Compiled with support for Windows Multimedia Extension (for audio).
Definition api.h:177
int compiler_version
Compiler version specifier.
Definition api.h:172
bj_bool feature_alsa
Compiled with support for ALSA (for audio).
Definition api.h:178
bj_bool config_checks_log
If checks feature is on, failed check with log.
Definition api.h:180
bj_bool config_log_color
Banjo logs will have colored output.
Definition api.h:181
const bj_build_info * bj_get_build_info(void)
Returns the build information of the runtime Banjo binaries.
uint32_t bj_bool
Boolean type used throughout the BJ codebase.
Definition api.h:143
Structure holding build information of the binary.
Definition api.h:168