Simple Graphics Library 1.0.0.0
Runtime-independent image processing primitives
Loading...
Searching...
No Matches
sgl-type.h
Go to the documentation of this file.
1/*
2 * SPDX-License-Identifier: MIT
3 *
4 * Copyright (c) 2025 Dylan Hong
5 *
6 * This code is released under the MIT License.
7 * For conditions of distribution and use, see the LICENSE file.
8 */
9#ifndef SGL_TYPE_H_
10#define SGL_TYPE_H_
11
21#if defined(__DOXYGEN__)
22
24typedef signed char sgl_int8_t;
26typedef unsigned char sgl_uint8_t;
28typedef signed short sgl_int16_t;
30typedef unsigned short sgl_uint16_t;
32typedef signed int sgl_int32_t;
34typedef unsigned int sgl_uint32_t;
36typedef signed long long sgl_int64_t;
38typedef unsigned long long sgl_uint64_t;
40typedef signed long sgl_intptr_t;
42typedef unsigned long sgl_uintptr_t;
44typedef unsigned long sgl_size_t;
46typedef signed long sgl_ptrdiff_t;
47
48#elif defined(_MSC_VER)
49
50typedef signed char sgl_int8_t;
51typedef unsigned char sgl_uint8_t;
52typedef signed short sgl_int16_t;
53typedef unsigned short sgl_uint16_t;
54typedef signed int sgl_int32_t;
55typedef unsigned int sgl_uint32_t;
56typedef signed __int64 sgl_int64_t;
57typedef unsigned __int64 sgl_uint64_t;
58
59#if defined(_WIN64)
60typedef signed __int64 sgl_intptr_t;
61typedef unsigned __int64 sgl_uintptr_t;
62typedef unsigned __int64 sgl_size_t;
63typedef signed __int64 sgl_ptrdiff_t;
64#else
65typedef signed int sgl_intptr_t;
66typedef unsigned int sgl_uintptr_t;
67typedef unsigned int sgl_size_t;
68typedef signed int sgl_ptrdiff_t;
69#endif
70
71#elif defined(__INT8_TYPE__) && defined(__UINT8_TYPE__) && \
72 defined(__INT16_TYPE__) && defined(__UINT16_TYPE__) && \
73 defined(__INT32_TYPE__) && defined(__UINT32_TYPE__) && \
74 defined(__INT64_TYPE__) && defined(__UINT64_TYPE__) && \
75 defined(__INTPTR_TYPE__) && defined(__UINTPTR_TYPE__) && \
76 defined(__SIZE_TYPE__) && defined(__PTRDIFF_TYPE__)
77
78typedef __INT8_TYPE__ sgl_int8_t;
79typedef __UINT8_TYPE__ sgl_uint8_t;
80typedef __INT16_TYPE__ sgl_int16_t;
81typedef __UINT16_TYPE__ sgl_uint16_t;
82typedef __INT32_TYPE__ sgl_int32_t;
83typedef __UINT32_TYPE__ sgl_uint32_t;
84typedef __INT64_TYPE__ sgl_int64_t;
85typedef __UINT64_TYPE__ sgl_uint64_t;
86typedef __INTPTR_TYPE__ sgl_intptr_t;
87typedef __UINTPTR_TYPE__ sgl_uintptr_t;
88typedef __SIZE_TYPE__ sgl_size_t;
89typedef __PTRDIFF_TYPE__ sgl_ptrdiff_t;
90
91#elif defined(__CPPCHECK__)
92
93typedef signed char sgl_int8_t;
94typedef unsigned char sgl_uint8_t;
95typedef signed short sgl_int16_t;
96typedef unsigned short sgl_uint16_t;
97typedef signed int sgl_int32_t;
98typedef unsigned int sgl_uint32_t;
99typedef signed long long sgl_int64_t;
100typedef unsigned long long sgl_uint64_t;
101typedef signed long sgl_intptr_t;
102typedef unsigned long sgl_uintptr_t;
103typedef unsigned long sgl_size_t;
104typedef signed long sgl_ptrdiff_t;
105
106#else
107#error "Unsupported compiler: fixed-width predefined types are unavailable"
108#endif
109
111typedef float sgl_float32_t;
113typedef double sgl_float64_t;
114
115#if defined(__cplusplus)
117typedef bool sgl_bool_t;
118#elif defined(_MSC_VER) && !defined(__clang__)
120typedef unsigned char sgl_bool_t;
121#else
123typedef _Bool sgl_bool_t;
124#endif
125
127#define SGL_FALSE ((sgl_bool_t)0)
129#define SGL_TRUE ((sgl_bool_t)1)
131#define SGL_SIZE_MAX (~(sgl_size_t)0U)
132
133#if defined(__cplusplus)
135#define SGL_NULL 0
136#else
138#define SGL_NULL ((void *)0)
139#endif
142#endif /* SGL_TYPE_H_ */
signed long sgl_intptr_t
Signed integer capable of representing an object pointer.
Definition sgl-type.h:40
unsigned long sgl_uintptr_t
Unsigned integer capable of representing an object pointer.
Definition sgl-type.h:42
signed short sgl_int16_t
Signed integer with exactly 16 value bits.
Definition sgl-type.h:28
double sgl_float64_t
Double-precision floating-point value.
Definition sgl-type.h:113
unsigned long long sgl_uint64_t
Unsigned integer with exactly 64 value bits.
Definition sgl-type.h:38
signed long sgl_ptrdiff_t
Signed type used for pointer differences.
Definition sgl-type.h:46
unsigned short sgl_uint16_t
Unsigned integer with exactly 16 value bits.
Definition sgl-type.h:30
float sgl_float32_t
Single-precision floating-point value.
Definition sgl-type.h:111
signed long long sgl_int64_t
Signed integer with exactly 64 value bits.
Definition sgl-type.h:36
signed char sgl_int8_t
Signed integer with exactly 8 value bits.
Definition sgl-type.h:24
_Bool sgl_bool_t
Boolean type mapped to the language/compiler representation.
Definition sgl-type.h:123
signed int sgl_int32_t
Signed integer with exactly 32 value bits.
Definition sgl-type.h:32
unsigned int sgl_uint32_t
Unsigned integer with exactly 32 value bits.
Definition sgl-type.h:34
unsigned long sgl_size_t
Unsigned type used for object sizes and byte counts.
Definition sgl-type.h:44
unsigned char sgl_uint8_t
Unsigned integer with exactly 8 value bits.
Definition sgl-type.h:26