zserge / jsmn

Jsmn is a world fastest JSON parser/tokenizer. This is the official repo replacing the old one at Bitbucket
MIT License
3.65k stars 778 forks source link

ifdef in struct definition #145

Closed kjhermans closed 5 years ago

kjhermans commented 5 years ago

If you have an #ifdef in your structure definitions, the size of your structure, as perceived by the compiler, may vary, depending on whether the user is compiling the .c file themselves or not / have the #define on or off in different Makefiles. I suggest to take away the #ifdef JSMN_PARENT_LINKS in the jsmntok_t.

pt300 commented 5 years ago

I'd suggest it's left intact as this helps reduce JSMN's memory footprint in memory-constrained environments like microcontrollers (and I think this library is actually often used in those). If it's really problematic I think a different solution should be implemented.

kjhermans commented 5 years ago

But you malloc() those things, right? the jsmntok_t's, I mean.

pt300 commented 5 years ago

Allocate them yourself, yes.

kjhermans commented 5 years ago

Ok. I suppose I'll just have to stick with forcibly defining the macro in the header file itself, as a patch.

pt300 commented 5 years ago

Now as the library is just a .h file it's not a problem anymore