Merge pull request #534 from smcv/c11-funcptr-noreturn

Add a separate noreturn macro for function pointers
This commit is contained in:
Yamagi 2020-03-23 18:12:13 +01:00 committed by GitHub
commit fdef98ffc0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 2 deletions

View file

@ -198,7 +198,7 @@ typedef struct
typedef struct
{
YQ2_ATTR_NORETURN void (IMPORT *Sys_Error) (int err_level, char *str, ...) __attribute__ ((format (printf, 2, 3)));
YQ2_ATTR_NORETURN_FUNCPTR void (IMPORT *Sys_Error) (int err_level, char *str, ...) __attribute__ ((format (printf, 2, 3)));
void (IMPORT *Cmd_AddCommand) (char *name, void(*cmd)(void));
void (IMPORT *Cmd_RemoveCommand) (char *name);

View file

@ -75,6 +75,16 @@ typedef unsigned char byte;
#define YQ2_ATTR_NORETURN
#endif
#if defined(__GNUC__)
/* ISO C11 _Noreturn can't be attached to function pointers, so
* use the gcc/clang-specific version for function pointers, even
* in C11 mode. MSVC __declspec(noreturn) seems to have the same
* restriction as _Noreturn so can't be used here either. */
#define YQ2_ATTR_NORETURN_FUNCPTR __attribute__ ((noreturn))
#else
#define YQ2_ATTR_NORETURN_FUNCPTR /* nothing */
#endif
/* angle indexes */
#define PITCH 0 /* up / down */
#define YAW 1 /* left / right */

View file

@ -120,7 +120,7 @@ typedef struct
they connect, and changes are sent to all connected clients. */
void (*configstring)(int num, char *string);
YQ2_ATTR_NORETURN void (*error)(char *fmt, ...);
YQ2_ATTR_NORETURN_FUNCPTR void (*error)(char *fmt, ...);
/* the *index functions create configstrings
and some internal server state */