Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/natsp.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,15 @@ static inline bool nats_StringEquals(const char *s1, const char *s2)
#define NATS_MILLIS_TO_NANOS(d) (((int64_t)d)*(int64_t)1E6)
#define NATS_SECONDS_TO_NANOS(d) (((int64_t)d)*(int64_t)1E9)

#if __STDC_VERSION__ >= 201112L
#define NATS_GLOBAL_STATIC_ASSERT(_cond, _message_as_id) \
_Static_assert(_cond, #_message_as_id)
#else
// for C99 we define explicitly
#define NATS_GLOBAL_STATIC_ASSERT(_cond, _message_as_id) \
typedef char static_assertion_##_message_as_id[(_cond) ? 1 : -1]
#endif

extern int64_t gLockSpinCount;

typedef void (*natsInitOnceCb)(void);
Expand Down
2 changes: 2 additions & 0 deletions src/status.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ static const char *statusText[] = {
"Jetstream Consumer PinID Mismatch",
};

NATS_GLOBAL_STATIC_ASSERT(NATS_MAX_STATUS_VALUE == sizeof(statusText)/sizeof(statusText[0]), Incorrect_array_size);

const char*
natsStatus_GetText(natsStatus s) {
return statusText[(int) s];
Expand Down