Skip to content

Commit

Permalink
Add UNUSED macro
Browse files Browse the repository at this point in the history
Suppresses `unused parameter` warnings with GCC and CLANG
  • Loading branch information
baylej committed Jan 8, 2016
1 parent 188d1a3 commit 93e1aa7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/tmx_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,11 @@ char* b64_decode(const char *source, unsigned int *rlength) { /* NULL terminated
#ifdef WANT_ZLIB
#include <zlib.h>

void* z_alloc(void *opaque, unsigned int items, unsigned int size) {
void* z_alloc(void *opaque UNUSED, unsigned int items, unsigned int size) {
return tmx_alloc_func(NULL, items *size);
}

void z_free(void *opaque, void *address) {
void z_free(void *opaque UNUSED, void *address) {
tmx_free_func(address);
}

Expand Down
7 changes: 7 additions & 0 deletions src/tmx_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@
#ifndef TMXUTILS_H
#define TMXUTILS_H

/* UNUSED macro to suppress `unused parameter` warnings with GCC and CLANG */
#ifdef __GNUC__
#define UNUSED __attribute__((__unused__))
#else
#define UNUSED
#endif

/*
Parser implementations
*/
Expand Down
2 changes: 1 addition & 1 deletion src/tmx_xml.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ static void* tmx_malloc(size_t len) {
On failure tmx_errno is set and and an error message is generated.
*/

static void error_handler(void *arg, const char *msg, xmlParserSeverities severity, xmlTextReaderLocatorPtr locator) {
static void error_handler(void *arg UNUSED, const char *msg, xmlParserSeverities severity, xmlTextReaderLocatorPtr locator) {
if (severity == XML_PARSER_SEVERITY_ERROR) {
tmx_err(E_XDATA, "xml parser: error at line %d: %s", xmlTextReaderLocatorLineNumber(locator), msg);
}
Expand Down

0 comments on commit 93e1aa7

Please sign in to comment.