Skip to content

Commit ad2fb17

Browse files
authored
Add stdint.readme file for toolchains that dont support stdint.h (#75)
Add a stdint.readme file that can be used for toolchains that do not support the stdint.h standard C header file. This makes the library ISO C90 compliant.
1 parent d69b11e commit ad2fb17

File tree

3 files changed

+39
-1
lines changed

3 files changed

+39
-1
lines changed

.github/workflows/ci.yml

+1
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ jobs:
155155
run: |
156156
mkdir -p override-include
157157
cp source/include/stdbool.readme override-include/stdbool.h
158+
cp source/include/stdint.readme override-include/stdint.h
158159
cmake -S test -B build/ \
159160
-G "Unix Makefiles" \
160161
-DBUILD_CLONE_SUBMODULES=ON \

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ A search may descend through nested objects when the `queryKey` contains matchin
5353

5454
A compiler that supports **C90 or later** such as *gcc* is required to build the library.
5555

56-
The library uses a header file introduced in ISO C99, `stdbool.h`. For compilers that do not provide this header file, the [source/include](source/include) directory contains [stdbool.readme](source/include/stdbool.readme), which can be renamed to `stdbool.h`.
56+
Additionally, the library uses 2 header files introduced in ISO C99, `stdbool.h` and `stdint.h`. For compilers that do not provide this header file, the [source/include](source/include) directory contains [stdbool.readme](source/include/stdbool.readme) and [stdbool.readme](source/include/stdint.readme), which can be renamed to `stdbool.h` and `stdint.h` respectively.
5757

5858
For instance, if the example above is copied to a file named `example.c`, *gcc* can be used like so:
5959
```bash

source/include/stdint.readme

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#ifndef _STDINT_H
2+
#define _STDINT_H
3+
4+
/*******************************************************************************
5+
* THIS IS NOT A FULL stdint.h IMPLEMENTATION - It only contains the definitions
6+
* necessary to build the library code. It is provided to allow the library to
7+
* be built using compilers that do not provide their own stdint.h definition.
8+
*
9+
* To use this file:
10+
*
11+
* 1) Copy this file into a directory that is in your compiler's include path.
12+
* The directory must be part of the include path for system header file,
13+
* for example passed using gcc's "-I" or "-isystem" options.
14+
*
15+
* 2) Rename the copied file stdint.h.
16+
*
17+
*/
18+
19+
typedef signed char int8_t;
20+
typedef unsigned char uint8_t;
21+
typedef short int16_t;
22+
typedef unsigned short uint16_t;
23+
typedef long int32_t;
24+
typedef unsigned long uint32_t;
25+
typedef long long int64_t;
26+
typedef unsigned long long uint64_t;
27+
28+
#define INT8_MAX ( ( signed char ) 127 )
29+
#define UINT8_MAX ( ( unsigned char ) 255 )
30+
#define INT16_MAX ( ( short ) 32767 )
31+
#define UINT16_MAX ( ( unsigned short ) 65535 )
32+
#define INT32_MAX 2147483647L
33+
#define UINT32_MAX 4294967295UL
34+
#define INT64_MAX 9223372036854775807LL
35+
#define UINT64_MAX 18446744073709551615ULL
36+
37+
#endif /* _STDINT_H */

0 commit comments

Comments
 (0)