From eeefc4ba3bae55d5f7469894f8ba8f4b604f2e0b Mon Sep 17 00:00:00 2001 From: Zeex Date: Thu, 2 Apr 2015 15:40:46 +0600 Subject: [PATCH] Fix compile warnings --- source/amx/amx.h | 14 ++++++++++++++ source/amx/amxdbg.h | 15 ++++++++++++++- source/compiler/pawndisasm.c | 36 ++++++++++++++++++++---------------- source/compiler/sc.h | 22 ++++++++++++++++++++++ source/compiler/sc1.c | 6 +++--- source/compiler/sc2.c | 2 +- source/compiler/sclist.c | 32 +++----------------------------- 7 files changed, 77 insertions(+), 50 deletions(-) diff --git a/source/amx/amx.h b/source/amx/amx.h index 07b9b7e..4c74986 100644 --- a/source/amx/amx.h +++ b/source/amx/amx.h @@ -204,6 +204,14 @@ typedef int (AMXAPI *AMX_IDLE)(struct tagAMX *amx, int AMXAPI Exec(struct tagAMX #define AMX_NO_ALIGN #endif +#if defined __GNUC__ + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wattributes" +#elif defined __clang__ + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wignored-attributes" +#endif + #if defined __GNUC__ #define PACKED __attribute__((packed)) #else @@ -461,6 +469,12 @@ int AMXAPI amx_UTF8Put(char *string, char **endptr, int maxchars, cell value); #endif #endif +#if defined __GNUC__ + #pragma GCC diagnostic pop +#elif defined __clang__ + #pragma clang diagnostic pop +#endif + #ifdef __cplusplus } #endif diff --git a/source/amx/amxdbg.h b/source/amx/amxdbg.h index 4609ff5..c011529 100644 --- a/source/amx/amxdbg.h +++ b/source/amx/amxdbg.h @@ -42,6 +42,14 @@ extern "C" { #define AMX_NO_ALIGN #endif +#if defined __GNUC__ + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wattributes" +#elif defined __clang__ + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wignored-attributes" +#endif + #if defined __GNUC__ #define PACKED __attribute__((packed)) #else @@ -154,7 +162,6 @@ int AMXAPI dbg_GetTagName(AMX_DBG *amxdbg, int tag, const char **name); int AMXAPI dbg_GetVariable(AMX_DBG *amxdbg, const char *symname, ucell scopeaddr, const AMX_DBG_SYMBOL **sym); int AMXAPI dbg_GetArrayDim(AMX_DBG *amxdbg, const AMX_DBG_SYMBOL *sym, const AMX_DBG_SYMDIM **symdim); - #if !defined AMX_NO_ALIGN #if defined LINUX || defined __FreeBSD__ #pragma pack() /* reset default packing */ @@ -165,6 +172,12 @@ int AMXAPI dbg_GetArrayDim(AMX_DBG *amxdbg, const AMX_DBG_SYMBOL *sym, const AMX #endif #endif +#if defined __GNUC__ + #pragma GCC diagnostic pop +#elif defined __clang__ + #pragma clang diagnostic pop +#endif + #ifdef __cplusplus } #endif diff --git a/source/compiler/pawndisasm.c b/source/compiler/pawndisasm.c index 88cb506..b592f4b 100644 --- a/source/compiler/pawndisasm.c +++ b/source/compiler/pawndisasm.c @@ -220,7 +220,7 @@ static OPCODE opcodelist[] = { void print_opcode(FILE *ftxt,cell opcode,cell cip) { - fprintf(ftxt,"%08lx %s ",cip,opcodelist[(int)(opcode &0x0000ffff)].name); + fprintf(ftxt,"%08"PRIxC" %s ",cip,opcodelist[(int)(opcode &0x0000ffff)].name); } void print_funcname(FILE *ftxt,cell address) @@ -228,7 +228,7 @@ void print_funcname(FILE *ftxt,cell address) int idx,numpublics; AMX_FUNCSTUBNT func; char name[sNAMEMAX+1]={'\0'}; - char *dbgname; + const char *dbgname; /* first look up the address in the debug info and, if failed, find it * in the public function table */ @@ -260,35 +260,38 @@ cell parm0(FILE *ftxt,const cell *params,cell opcode,cell cip) cell parm1(FILE *ftxt,const cell *params,cell opcode,cell cip) { print_opcode(ftxt,opcode,cip); - fprintf(ftxt,"%08lx\n",*params); + fprintf(ftxt,"%08"PRIxC"\n",*params); return 2; } cell parm2(FILE *ftxt,const cell *params,cell opcode,cell cip) { print_opcode(ftxt,opcode,cip); - fprintf(ftxt,"%08lx %08lx\n",params[0],params[1]); + fprintf(ftxt,"%08"PRIxC" %08"PRIxC"\n",params[0],params[1]); return 3; } cell parm3(FILE *ftxt,const cell *params,cell opcode,cell cip) { print_opcode(ftxt,opcode,cip); - fprintf(ftxt,"%08lx %08lx %08lx\n",params[0],params[1],params[2]); + fprintf(ftxt,"%08"PRIxC" %08"PRIxC" %08"PRIxC"\n", + params[0],params[1],params[2]); return 4; } cell parm4(FILE *ftxt,const cell *params,cell opcode,cell cip) { print_opcode(ftxt,opcode,cip); - fprintf(ftxt,"%08lx %08lx %08lx %08lx\n",params[0],params[1],params[2],params[3]); + fprintf(ftxt,"%08"PRIxC" %08"PRIxC" %08"PRIxC" %08"PRIxC"\n", + params[0],params[1],params[2],params[3]); return 5; } cell parm5(FILE *ftxt,const cell *params,cell opcode,cell cip) { print_opcode(ftxt,opcode,cip); - fprintf(ftxt,"%08lx %08lx %08lx %08lx %08lx\n",params[0],params[1],params[2],params[3],params[4]); + fprintf(ftxt,"%08"PRIxC" %08"PRIxC" %08"PRIxC" %08"PRIxC" %08"PRIxC"\n", + params[0],params[1],params[2],params[3],params[4]); return 6; } @@ -303,7 +306,7 @@ cell do_proc(FILE *ftxt,const cell *params,cell opcode,cell cip) cell do_call(FILE *ftxt,const cell *params,cell opcode,cell cip) { print_opcode(ftxt,opcode,cip); - fprintf(ftxt,"%08lx",*params); + fprintf(ftxt,"%08"PRIxC,*params); print_funcname(ftxt,*params); fputs("\n",ftxt); return 2; @@ -312,7 +315,7 @@ cell do_call(FILE *ftxt,const cell *params,cell opcode,cell cip) cell do_jump(FILE *ftxt,const cell *params,cell opcode,cell cip) { print_opcode(ftxt,opcode,cip); - fprintf(ftxt,"%08lx\n",*params); + fprintf(ftxt,"%08"PRIxC"\n",*params); return 2; } @@ -338,7 +341,7 @@ cell do_sysreq(FILE *ftxt,const cell *params,cell opcode,cell cip) } /* if */ print_opcode(ftxt,opcode,cip); - fprintf(ftxt,"%08lx",*params); + fprintf(ftxt,"%08"PRIxC,*params); if (strlen(name)>0) fprintf(ftxt,"\t; %s",name); fprintf(ftxt,"\n"); @@ -348,7 +351,7 @@ cell do_sysreq(FILE *ftxt,const cell *params,cell opcode,cell cip) cell do_switch(FILE *ftxt,const cell *params,cell opcode,cell cip) { print_opcode(ftxt,opcode,cip); - fprintf(ftxt,"%08lx\n",*params+cip); + fprintf(ftxt,"%08"PRIxC"\n",*params+cip); return 2; } @@ -359,9 +362,10 @@ cell casetbl(FILE *ftxt,const cell *params,cell opcode,cell cip) print_opcode(ftxt,opcode,cip); num=params[0]+1; - fprintf(ftxt,"%08lx %08lx\n",params[0],params[1]); + fprintf(ftxt,"%08"PRIxC" %08"PRIxC"\n",params[0],params[1]); for (idx=1; idx=199901L + #define __STDC_FORMAT_MACROS + #define __STDC_CONSTANT_MACROS + #include /* automatically includes stdint.h */ +#elif (defined _MSC_VER || defined __BORLANDC__) && (defined _I64_MAX || defined HAVE_I64) + #define PRId64 "I64d" + #define PRIx64 "I64x" +#else + #define PRId64 "lld" + #define PRIx64 "llx" +#endif +#if PAWN_CELL_SIZE==64 + #define PRIdC PRId64 + #define PRIxC PRIx64 +#else + #define PRIdC "d" + #define PRIxC "x" +#endif + #endif /* SC_H_INCLUDED */ diff --git a/source/compiler/sc1.c b/source/compiler/sc1.c index af58381..102cc4b 100644 --- a/source/compiler/sc1.c +++ b/source/compiler/sc1.c @@ -4171,7 +4171,7 @@ static void make_report(symbol *root,FILE *log,char *sourcefile) continue; if ((sym->usage & uREAD)==0) continue; - fprintf(log,"\t\t\n",funcdisplayname(symname,sym->name),sym->addr); + fprintf(log,"\t\t\n",funcdisplayname(symname,sym->name),sym->addr); if (sym->tag!=0) { tagsym=find_tag_byval(sym->tag); assert(tagsym!=NULL); @@ -4181,7 +4181,7 @@ static void make_report(symbol *root,FILE *log,char *sourcefile) if ((enumroot=sym->dim.enumlist)!=NULL) { enumroot=enumroot->next; /* skip root */ while (enumroot!=NULL) { - fprintf(log,"\t\t\t\n",funcdisplayname(symname,enumroot->name),enumroot->value); + fprintf(log,"\t\t\t\n",funcdisplayname(symname,enumroot->name),enumroot->value); /* find the constant with this name and get the tag */ ref=findglb(enumroot->name,sGLOBAL); if (ref!=NULL) { @@ -4217,7 +4217,7 @@ static void make_report(symbol *root,FILE *log,char *sourcefile) continue; if ((sym->usage & uREAD)==0 || (sym->usage & (uENUMFIELD | uENUMROOT))!=0) continue; - fprintf(log,"\t\t\n",funcdisplayname(symname,sym->name),sym->addr); + fprintf(log,"\t\t\n",funcdisplayname(symname,sym->name),sym->addr); if (sym->tag!=0) { tagsym=find_tag_byval(sym->tag); assert(tagsym!=NULL); diff --git a/source/compiler/sc2.c b/source/compiler/sc2.c index 1d78d60..afd95f0 100644 --- a/source/compiler/sc2.c +++ b/source/compiler/sc2.c @@ -638,7 +638,7 @@ static int htoi(cell *val,const unsigned char *curptr) } #if defined __GNUC__ -static double pow10(int value) +static double pow10(double value) { double res=1.0; while (value>=4) { diff --git a/source/compiler/sclist.c b/source/compiler/sclist.c index d52f9f1..a9f0279 100644 --- a/source/compiler/sclist.c +++ b/source/compiler/sclist.c @@ -38,7 +38,7 @@ /* a "private" implementation of strdup(), so that porting * to other memory allocators becomes easier. - * By Søren Hannibal. + * By S�ren Hannibal. */ SC_FUNC char* duplicatestring(const char* sourcestring) { @@ -138,7 +138,7 @@ static int delete_stringpair(stringpair *root,stringpair *item) static stringlist *insert_string(stringlist *list,char *string) { stringlist newlist; - + assert(list!=NULL); assert(string!=NULL); if (list->data==NULL) { @@ -193,7 +193,7 @@ static int delete_string(stringlist *list,int index) SC_FUNC void delete_stringtable(stringlist *list) { int i; - + assert(list!=NULL); for (i=0; isize; i++) free(list->data[i]); @@ -436,32 +436,6 @@ SC_FUNC void delete_heaplisttable(void) /* ----- debug information --------------------------------------- */ - -/* These macros are adapted from LibDGG libdgg-int64.h, see - * http://www.dennougedougakkai-ndd.org/pub/libdgg/ - */ -#if defined(__STDC_VERSION__) && __STDC_VERSION__>=199901L - #define __STDC_FORMAT_MACROS - #define __STDC_CONSTANT_MACROS - #include /* automatically includes stdint.h */ -#elif (defined _MSC_VER || defined __BORLANDC__) && (defined _I64_MAX || defined HAVE_I64) - #define PRId64 "I64d" - #define PRIx64 "I64x" -#else - #define PRId64 "lld" - #define PRIx64 "llx" -#endif -#if PAWN_CELL_SIZE==64 - #define PRIdC PRId64 - #define PRIxC PRIx64 -#elif PAWN_CELL_SIZE==32 - #define PRIdC "ld" - #define PRIxC "lx" -#else - #define PRIdC "d" - #define PRIxC "x" -#endif - static stringlist dbgstrings = {NULL, NULL, 0, 0}; SC_FUNC stringlist *insert_dbgfile(const char *filename)