1. Serge Zaitsev
  2. jsmn
  3. Issues
Issue #24 new

jsmntype needs "empty" value

illishar
created an issue

When defining enums, one must always define the 0-entry as a "empty" value.

Eg.

typedef enum { JSMN_UNDEFINED = 0, JSMN_OBJECT = 1, JSMN_ARRAY = 2, JSMN_KEY = 3, JSMN_STRING_PRIMITIVE = 4, JSMN_PRIMITIVE = 5 } jsmntype_t;

This will solve a lot of small issues. (Especially in ANSI C.) The following constructs will now produce "legal" code.

struct my_struct_containing_jsmntype foo = {0};

Or

memset(&foo, 0, sizeof(struct my_struct_containing_jsmntype));

It's a lifesaver.

Comments (0)

  1. Log in to comment