README: Add Caveats section

This commit is contained in:
Max Bruckner 2017-04-08 02:16:40 +02:00
parent c784f76c77
commit 50b3c30dfa

View File

@ -9,6 +9,7 @@ Ultralightweight JSON parser in ANSI C.
* [Building](#building) * [Building](#building)
* [Some JSON](#some-json) * [Some JSON](#some-json)
* [Here's the structure](#heres-the-structure) * [Here's the structure](#heres-the-structure)
* [Caveats](#caveats)
* [Enjoy cJSON!](#enjoy-cjson) * [Enjoy cJSON!](#enjoy-cjson)
## License ## License
@ -372,6 +373,28 @@ The `test.c` code shows how to handle a bunch of typical cases. If you uncomment
the code, it'll load, parse and print a bunch of test files, also from [json.org](http://json.org), the code, it'll load, parse and print a bunch of test files, also from [json.org](http://json.org),
which are more complex than I'd care to try and stash into a `const char array[]`. which are more complex than I'd care to try and stash into a `const char array[]`.
### Caveats
#### C Standard
cJSON is written in ANSI C (or C89, C90). If your compiler or C library doesn't follow this standard, correct behavior is not guaranteed.
NOTE: ANSI C is not C++ therefore it shouldn't be compiled by a C++ compiler. You can compile it with a C compiler and link it with your C++ code however. Although compiling with a C++ compiler might work, correct behavior is not guaranteed.
#### Floating Point Numbers
cJSON does not officially support any `double` implementations other than IEE754 double precision floating point numbers. It might still work with other implementations but bugs with these will be considered invalid.
The maximum length of a floating point literal that cJSON supports is currently 63 characters.
#### Thread Safety
In general cJSON is **not thread safe**.
However it is thread safe under the following conditions:
* You don't use `cJSON_GetErrorPtr` (you can use the `return_parse_end` parameter of `cJSON_ParseWithOpts` instead)
* You only ever call `cJSON_InitHooks` before using cJSON in any threads.
# Enjoy cJSON! # Enjoy cJSON!
- Dave Gamble, Aug 2009 - Dave Gamble, Aug 2009