diff --git a/include/commdef.h b/include/commdef.h index a15433b..463fa4c 100644 --- a/include/commdef.h +++ b/include/commdef.h @@ -35,6 +35,7 @@ #endif #include "cvar.h" +#include "gcc_attr.h" /* The host system specifies the base of the directory tree, the command line parms passed to the program, and the amount of memory @@ -61,7 +62,7 @@ extern qboolean host_initialized; /* True if into command execution. */ extern double realtime; /* Not bounded in any way, changed at start of every frame, never reset */ -char *va(char *format, ...); +char *va(char *format, ...) __attribute__((format(printf,1,2))); // does a varargs printf into a temp buffer #endif // _COMMDEF_H diff --git a/include/console.h b/include/console.h index b7ca799..692358d 100644 --- a/include/console.h +++ b/include/console.h @@ -33,6 +33,7 @@ // #include "qtypes.h" +#include "gcc_attr.h" #define CON_TEXTSIZE 16384 typedef struct @@ -61,9 +62,9 @@ void Con_CheckResize (void); void Con_Init (void); void Con_DrawConsole (int lines); void Con_Print (char *txt); -void Con_Printf (char *fmt, ...); -void Con_DPrintf (char *fmt, ...); -void Con_SafePrintf (char *fmt, ...); +void Con_Printf (char *fmt, ...) __attribute__((format(printf,1,2))); +void Con_DPrintf (char *fmt, ...) __attribute__((format(printf,1,2))); +void Con_SafePrintf (char *fmt, ...) __attribute__((format(printf,1,2))); void Con_Clear_f (void); void Con_DrawNotify (void); void Con_ClearNotify (void); diff --git a/include/gcc_attr.h b/include/gcc_attr.h new file mode 100644 index 0000000..1819920 --- /dev/null +++ b/include/gcc_attr.h @@ -0,0 +1,36 @@ +/* + gcc_attr.h + + GCC __attribute__ protection for lame compilers. + + Copyright (C) 1996-1997 Id Software, Inc. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + + See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to: + + Free Software Foundation, Inc. + 59 Temple Place - Suite 330 + Boston, MA 02111-1307, USA + + $Id$ +*/ + +#ifndef _GCC_ATTR_H +#define _GCC_ATTR_H + +#ifndef __GNUC__ +#define __attribute__(x) +#endif + +#endif // _GCC_ATTR_H diff --git a/include/net.h b/include/net.h index c567cb8..dfd2c1e 100644 --- a/include/net.h +++ b/include/net.h @@ -29,6 +29,7 @@ #ifndef _NET_H #define _NET_H +#include "gcc_attr.h" #include "sizebuf.h" #include "cvar.h" @@ -116,7 +117,7 @@ extern int net_drop; // packets dropped before this one void Netchan_Init (void); void Netchan_Transmit (netchan_t *chan, int length, byte *data); void Netchan_OutOfBand (netadr_t adr, int length, byte *data); -void Netchan_OutOfBandPrint (netadr_t adr, char *format, ...); +void Netchan_OutOfBandPrint (netadr_t adr, char *format, ...) __attribute__((format(printf,2,3))); qboolean Netchan_Process (netchan_t *chan); void Netchan_Setup (netchan_t *chan, netadr_t adr, int qport); diff --git a/include/progs.h b/include/progs.h index d4c2311..8f7b342 100644 --- a/include/progs.h +++ b/include/progs.h @@ -29,6 +29,7 @@ #ifndef _PROGS_H #define _PROGS_H +#include "gcc_attr.h" #include "protocol.h" #include "pr_comp.h" // defs shared with qcc #include "progdefs.h" // generated by program cdefs @@ -140,7 +141,7 @@ extern func_t SpectatorConnect; extern func_t SpectatorThink; extern func_t SpectatorDisconnect; -void PR_RunError (char *error, ...); +void PR_RunError (char *error, ...) __attribute__((format(printf,1,2))); void ED_PrintEdicts (void); void ED_PrintNum (int ent); diff --git a/include/quakedef.h b/include/quakedef.h index 3cf4243..1f621f7 100644 --- a/include/quakedef.h +++ b/include/quakedef.h @@ -29,6 +29,8 @@ #ifndef _QUAKEDEF_H #define _QUAKEDEF_H +#include "gcc_attr.h" + #define QUAKE_GAME // as opposed to utilities //define PARANOID // speed sapping error checking @@ -71,12 +73,12 @@ void Host_ServerFrame (void); void Host_InitCommands (void); void Host_Init (quakeparms_t *parms); void Host_Shutdown(void); -void Host_Error (char *error, ...); -void Host_EndGame (char *message, ...); +void Host_Error (char *error, ...) __attribute__((format(printf,1,2))); +void Host_EndGame (char *message, ...) __attribute__((format(printf,1,2))); qboolean Host_SimulationTime(float time); void Host_Frame (float time); void Host_Quit_f (void); -void Host_ClientCommands (char *fmt, ...); +void Host_ClientCommands (char *fmt, ...) __attribute__((format(printf,1,2))); void Host_ShutdownServer (qboolean crash); #endif // _QUAKEDEH_H diff --git a/include/quakeio.h b/include/quakeio.h index 3db19d6..9004de7 100644 --- a/include/quakeio.h +++ b/include/quakeio.h @@ -30,6 +30,7 @@ #ifndef _QUAKEIO_H #define _QUAKEIO_H +#include "gcc_attr.h" #include #include @@ -41,7 +42,7 @@ FILE *Qdopen(int fd, const char *mode); void Qclose(FILE *file); int Qread(FILE *file, void *buf, int count); int Qwrite(FILE *file, void *buf, int count); -int Qprintf(FILE *file, const char *fmt, ...); +int Qprintf(FILE *file, const char *fmt, ...) __attribute__((format(printf,2,3))); char *Qgets(FILE *file, char *buf, int count); int Qgetc(FILE *file); int Qputc(FILE *file, int c); diff --git a/include/server.h b/include/server.h index 3120718..7f0f31f 100644 --- a/include/server.h +++ b/include/server.h @@ -30,6 +30,7 @@ #ifndef _SERVER_H #define _SERVER_H +#include "gcc_attr.h" #include "commdef.h" #include "net.h" #include "cvar.h" @@ -369,11 +370,11 @@ extern double sv_frametime; //=========================================================== // FIXME: declare exported functions in their own relevant .h -void SV_Error (char *error, ...); +void SV_Error (char *error, ...) __attribute__((format(printf,1,2))); void SV_Init (quakeparms_t *parms); -void Con_Printf (char *fmt, ...); -void Con_DPrintf (char *fmt, ...); +void Con_Printf (char *fmt, ...) __attribute__((format(printf,1,2))); +void Con_DPrintf (char *fmt, ...) __attribute__((format(printf,1,2))); // // sv_main.c @@ -436,9 +437,9 @@ void SV_SendClientMessages (void); void SV_Multicast (vec3_t origin, int to); void SV_StartSound (edict_t *entity, int channel, char *sample, int volume, float attenuation); -void SV_ClientPrintf (client_t *cl, int level, char *fmt, ...); -void SV_BroadcastPrintf (int level, char *fmt, ...); -void SV_BroadcastCommand (char *fmt, ...); +void SV_ClientPrintf (client_t *cl, int level, char *fmt, ...) __attribute__((format(printf,3,4))); +void SV_BroadcastPrintf (int level, char *fmt, ...) __attribute__((format(printf,2,3))); +void SV_BroadcastCommand (char *fmt, ...) __attribute__((format(printf,1,2))); void SV_SendMessagesToAll (void); void SV_FindModelNumbers (void); diff --git a/include/sys.h b/include/sys.h index 6ab608e..9bd2eec 100644 --- a/include/sys.h +++ b/include/sys.h @@ -29,6 +29,8 @@ #ifndef _SYS_H #define _SYS_H +#include "gcc_attr.h" + // // file IO // @@ -54,12 +56,12 @@ void Sys_MakeCodeWriteable (unsigned long startaddr, unsigned long length); // // system IO // -void Sys_DebugLog(char *file, char *fmt, ...); +void Sys_DebugLog(char *file, char *fmt, ...) __attribute__((format(printf,2,3))); -void Sys_Error (char *error, ...); +void Sys_Error (char *error, ...) __attribute__((format(printf,1,2))); // an error will cause the entire program to exit -void Sys_Printf (char *fmt, ...); +void Sys_Printf (char *fmt, ...) __attribute__((format(printf,1,2))); // send text to the console void Sys_Quit (void); @@ -76,7 +78,7 @@ void Sys_LowFPPrecision (void); void Sys_HighFPPrecision (void); void Sys_SetFPCW (void); -void Sys_Printf (char *fmt, ...); +void Sys_Printf (char *fmt, ...) __attribute__((format(printf,1,2))); // send text to the console void Sys_Init (void); diff --git a/source/cl_parse.c b/source/cl_parse.c index db0544d..83cd4eb 100644 --- a/source/cl_parse.c +++ b/source/cl_parse.c @@ -1258,13 +1258,13 @@ void CL_ParseServerMessage (void) for (i=0 ; i<3 ; i++) { cl.simorg[i] = MSG_ReadCoord (); - Con_DPrintf ("%i ", cl.simorg[i]); + Con_DPrintf ("%f ", cl.simorg[i]); } Con_DPrintf ("\nintermission simangles: "); for (i=0 ; i<3 ; i++) { cl.simangles[i] = MSG_ReadAngle (); - Con_DPrintf ("%i ", cl.simangles[i]); + Con_DPrintf ("%f ", cl.simangles[i]); } Con_DPrintf ("\n"); VectorCopy (vec3_origin, cl.simvel); diff --git a/source/vid_x11.c b/source/vid_x11.c index 670a5e9..02a46fb 100644 --- a/source/vid_x11.c +++ b/source/vid_x11.c @@ -557,7 +557,7 @@ void VID_Init (unsigned char *palette) printf(" -visualid %d\n", (int)(x_visinfo[i].visualid)); } else if (num_visuals == 0) { if (template_mask == VisualIDMask) { - Sys_Error("VID: Bad visual id %d\n", + Sys_Error("VID: Bad visual id %ld\n", template.visualid); } else { Sys_Error("VID: No visuals at depth %d\n",