wren icon indicating copy to clipboard operation
wren copied to clipboard

Fix unused parameter warnings

Open RobLoach opened this issue 2 years ago • 1 comments

When compiling with -Wall -Wextra, there are a few unused-parameter warnings. See the entire list of unused parameter warnings.

While we don't really need to fix these up, it would be nice...

I propose in wren_common.h...

// Allow specifying unused parameters of a function.
#define WREN_UNUSED(x) (void)(x)

And then when there is an unused parameter, declare it.

// wren_opt_random.c
WrenForeignClassMethods wrenRandomBindForeignClass(WrenVM* vm,
                                                   const char* module,
                                                   const char* className)
{
  ASSERT(strcmp(className, "Random") == 0, "Should be in Random class.");
  WrenForeignClassMethods methods;
  methods.allocate = randomAllocate;
  methods.finalize = NULL;
  WREN_UNUSED(vm);
  return methods;
}

RobLoach avatar Nov 06 '21 17:11 RobLoach

To be more safe it should be:

#define WREN_UNUSED(x) ((void)(x))

Otherwise it is good for me.

mhermier avatar Nov 06 '21 22:11 mhermier