From 7c196762e4cabf5582116091bcf0818f4c2d612d Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Mon, 16 Nov 2020 13:53:45 -0800 Subject: thunk: mark functions w/gcc unused attribute This shuts up gcc warnings w/-Wall for thunked functions. It's expected there will be some unused functions, esp. since there's the split init/alloc variants one may or may not use. It's also nice in some scenarios to write a collection of small closures a project may or may not take advantage of at any given moment in its development. No point making a bunch of noise about it. --- thunk.h | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/thunk.h b/thunk.h index 4a8060e..7fbdfbd 100644 --- a/thunk.h +++ b/thunk.h @@ -440,7 +440,12 @@ struct thunk_t { * function definition, all in one place in one fell swoop. */ #define THUNK_DEFINE_STATIC(_name, ...) \ - static int _THUNK_GEN_PROTO(_name, __VA_ARGS__); \ + static int _THUNK_GEN_PROTO(_name, __VA_ARGS__) __attribute__ ((unused));\ + static int __thunk_dispatch_##_name(thunk_t *thunk) __attribute__ ((unused));\ + static thunk_t * __thunk_alloc_##_name(void **payload_ptr, size_t payload_size) __attribute__ ((unused));\ + static thunk_t * _THUNK_GEN_PROTO(__thunk_instantiate_##_name, __VA_ARGS__) __attribute__ ((unused));\ + static thunk_t * _THUNK_GEN_INIT_PROTO(__thunk_init_##_name, thunk_t *_thunk, __VA_ARGS__) __attribute__ ((unused));\ + \ typedef struct __thunk_environment_##_name { \ /* struct for encapsulating the calling environment */ \ thunk_t __thunk; \ @@ -511,7 +516,7 @@ struct thunk_t { * .h from the implementing .c - not just the consumers. */ #define THUNK_DECLARE(_name, ...) \ - int _THUNK_GEN_PROTO(_name, __VA_ARGS__); \ + int _THUNK_GEN_PROTO(_name, __VA_ARGS__) __attribute__ ((unused)); \ typedef struct __thunk_environment_##_name { \ /* struct for encapsulating the calling environment */ \ thunk_t __thunk; \ @@ -519,10 +524,10 @@ struct thunk_t { char __payload[]; \ } __thunk_environment_##_name; \ \ - int __thunk_dispatch_##_name(thunk_t *thunk); \ - thunk_t * _THUNK_GEN_INIT_PROTO(__thunk_init_##_name, thunk_t *_thunk, __VA_ARGS__);\ - thunk_t * __thunk_alloc_##_name(void **payload_ptr, size_t payload_size);\ - thunk_t * _THUNK_GEN_PROTO(__thunk_instantiate_##_name, __VA_ARGS__); + int __thunk_dispatch_##_name(thunk_t *thunk) __attribute__ ((unused)); \ + thunk_t * _THUNK_GEN_INIT_PROTO(__thunk_init_##_name, thunk_t *_thunk, __VA_ARGS__) __attribute__ ((unused));\ + thunk_t * __thunk_alloc_##_name(void **payload_ptr, size_t payload_size) __attribute__ ((unused));\ + thunk_t * _THUNK_GEN_PROTO(__thunk_instantiate_##_name, __VA_ARGS__) __attribute__ ((unused)); #define THUNK_DEFINE(_name, ...) \ -- cgit v1.2.3