-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Several of the macros define a block scope for local variables, but that doesn't force semicolons at build time. A common pattern is to use a do-while loop which does require a semicolon while preserving the block scope. The overhead of the do-while loop is complied out anyways.
For example, take:
NAPI_STATUS_RETURN(::napi_typeof(env, argv[0], &type))This builds just fine with the trailing semicolon, however this can lead to confusing code as we're using NAPI_* macros like they are functions.
To clean things up, we need to change macros like:
#define NAPI_STATUS_RETURN(call) \
{ \
napi_status status = (call); \
if (status != napi_ok) { \
return status; \
} \
}to:
#define NAPI_STATUS_RETURN(call) \
do { \
napi_status status = (call); \
if (status != napi_ok) { \
return status; \
} \
} while (0)Metadata
Metadata
Assignees
Labels
No labels