mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2025-01-31 13:20:34 +00:00
YQ2_ATTR_NORETURN for functions that don't return (Sys_Error() etc)
must be used in front of functions, not behind (the GCC __attribute__ allows both, but MSVC and C11 don't!)
This commit is contained in:
parent
0ad5c73239
commit
ae3723c900
6 changed files with 16 additions and 11 deletions
|
@ -198,7 +198,7 @@ typedef struct
|
|||
|
||||
typedef struct
|
||||
{
|
||||
void (IMPORT *Sys_Error) (int err_level, char *str, ...) __attribute__ ((format (printf, 2, 3)));
|
||||
YQ2_ATTR_NORETURN 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);
|
||||
|
|
|
@ -710,8 +710,8 @@ void Com_Printf(char *fmt, ...) __attribute__ ((format (printf, 1, 2)));
|
|||
void Com_DPrintf(char *fmt, ...) __attribute__ ((format (printf, 1, 2)));
|
||||
void Com_VPrintf(int print_level, const char *fmt, va_list argptr); /* print_level is PRINT_ALL or PRINT_DEVELOPER */
|
||||
void Com_MDPrintf(char *fmt, ...) __attribute__ ((format (printf, 1, 2)));
|
||||
void Com_Error(int code, char *fmt, ...) __attribute__ ((format (printf, 2, 3)));
|
||||
void Com_Quit(void);
|
||||
YQ2_ATTR_NORETURN void Com_Error(int code, char *fmt, ...) __attribute__ ((format (printf, 2, 3)));
|
||||
YQ2_ATTR_NORETURN void Com_Quit(void);
|
||||
|
||||
/* Ugly hack: Apprently (our?) MinGW-gcc under Windows
|
||||
doesn't support %zd and requires %Id. */
|
||||
|
@ -797,8 +797,8 @@ void SV_Frame(int msec);
|
|||
// system.c
|
||||
char *Sys_ConsoleInput(void);
|
||||
void Sys_ConsoleOutput(char *string);
|
||||
void Sys_Error(char *error, ...);
|
||||
void Sys_Quit(void);
|
||||
YQ2_ATTR_NORETURN void Sys_Error(char *error, ...);
|
||||
YQ2_ATTR_NORETURN void Sys_Quit(void);
|
||||
void Sys_Init(void);
|
||||
char *Sys_GetHomeDir(void);
|
||||
void Sys_Remove(const char *path);
|
||||
|
|
|
@ -53,19 +53,26 @@ typedef unsigned char byte;
|
|||
#define NULL ((void *)0)
|
||||
#endif
|
||||
|
||||
// stuff to align variables/arrays
|
||||
// stuff to align variables/arrays and for noreturn
|
||||
#if __STDC_VERSION__ >= 201112L // C11 or newer
|
||||
#define YQ2_ALIGNAS_SIZE(SIZE) _Alignas(SIZE)
|
||||
#define YQ2_ALIGNAS_TYPE(TYPE) _Alignas(TYPE)
|
||||
// must be used as prefix (YQ2_ATTR_NORETURN void bla();)!
|
||||
#define YQ2_ATTR_NORETURN _Noreturn
|
||||
#elif defined(__GNUC__) // GCC and clang should support this attribute
|
||||
#define YQ2_ALIGNAS_SIZE(SIZE) __attribute__(( __aligned__(SIZE) ))
|
||||
#define YQ2_ALIGNAS_TYPE(TYPE) __attribute__(( __aligned__(__alignof__(TYPE)) ))
|
||||
// must be used as prefix (YQ2_ATTR_NORETURN void bla();)!
|
||||
#define YQ2_ATTR_NORETURN __attribute__ ((noreturn))
|
||||
#elif defined(_MSC_VER)
|
||||
#define YQ2_ALIGNAS_SIZE(SIZE) __declspec( align(SIZE) )
|
||||
#define YQ2_ALIGNAS_TYPE(TYPE) __declspec( align( __alignof(TYPE) ) )
|
||||
// must be used as prefix (YQ2_ATTR_NORETURN void bla();)!
|
||||
#define YQ2_ATTR_NORETURN __declspec(noreturn)
|
||||
#else
|
||||
#warning "Please add a case for your compiler here to align correctly"
|
||||
#define YQ2_ALIGNAS_TYPE(TYPE)
|
||||
#define YQ2_ATTR_NORETURN
|
||||
#endif
|
||||
|
||||
/* angle indexes */
|
||||
|
@ -338,7 +345,7 @@ char *Sys_FindNext(unsigned musthave, unsigned canthave);
|
|||
void Sys_FindClose(void);
|
||||
|
||||
/* this is only here so the functions in shared source files can link */
|
||||
void Sys_Error(char *error, ...);
|
||||
YQ2_ATTR_NORETURN void Sys_Error(char *error, ...);
|
||||
void Com_Printf(char *msg, ...);
|
||||
|
||||
/*
|
||||
|
|
|
@ -120,7 +120,7 @@ typedef struct
|
|||
they connect, and changes are sent to all connected clients. */
|
||||
void (*configstring)(int num, char *string);
|
||||
|
||||
void (*error)(char *fmt, ...);
|
||||
YQ2_ATTR_NORETURN void (*error)(char *fmt, ...);
|
||||
|
||||
/* the *index functions create configstrings
|
||||
and some internal server state */
|
||||
|
|
|
@ -241,8 +241,6 @@ void SV_WriteFrameToClient(client_t *client, sizebuf_t *msg);
|
|||
void SV_RecordDemoMessage(void);
|
||||
void SV_BuildClientFrame(client_t *client);
|
||||
|
||||
void SV_Error(char *error, ...);
|
||||
|
||||
extern game_export_t *ge;
|
||||
|
||||
void SV_InitGameProgs(void);
|
||||
|
|
|
@ -149,7 +149,7 @@ PF_centerprintf(edict_t *ent, char *fmt, ...)
|
|||
/*
|
||||
* Abort the server with a game error
|
||||
*/
|
||||
void
|
||||
YQ2_ATTR_NORETURN void
|
||||
PF_error(char *fmt, ...)
|
||||
{
|
||||
char msg[1024];
|
||||
|
|
Loading…
Reference in a new issue