atsb / Doom64EX-Plus

An improved modern version of Doom64EX.
GNU General Public License v2.0
100 stars 16 forks source link

fixed gcc 13 compiler warnings #226

Closed bubbleguuum closed 4 months ago

bubbleguuum commented 4 months ago

mostly function pointer casts and other benign warnings one warning resulted in fixing inverted function parameters in g_demo.c

bubbleguuum commented 4 months ago

Ok I removed it although the proper cast to make the warning go away would have been int (*)( const void*, const void* ), which I admit is a bit ugly...

Wolf3s commented 4 months ago

Ok I removed it although the proper cast to make the warning go away would have been int (*)( const void*, const void* ), which I admit is a bit ugly...

well the function qsort itself it´s ugly, but i don´t recommend casting like you did.

Wolf3s commented 4 months ago

also there´s more suggestions: remove on SC_Data (int ()(void, void*)) cast and add and replace scparser_t on sc_main.h like this:

typedef struct {
    const char* token;
    int64_t   ptroffset;
    char    type;
} scdatatable_t;

typedef struct {
    char    token[512];
    byte* buffer;
    char* pointer_start;
    char* pointer_end;
    int     linepos;
    int     rowpos;
    int     buffpos;
    int     buffsize;
    void (*open)(const char*);
    void (*close)(void);
    void (*compare)(const char*);
    int (*find)(boolean);
    char(*fgetchar)(void);
    void (*rewind)(void);
    char* (*getstring)(void);
    int (*getint)(void);
    int (*setdata)(byte*, const scdatatable_t*);
    int (*readtokens)(void);
    void (*error)(const char*);
} scparser_t;
Wolf3s commented 4 months ago

byte and void are similar.

bubbleguuum commented 4 months ago

also there´s more suggestions: remove on SCData (int ()(void_, void*)) cast and add and replace scparser_t on sc_main.h like

Done.

bubbleguuum commented 4 months ago

byte and void are similar.

indeed but GCC (by default, without special flags) issue warnings on pointer function assignments if the signatures do not exactly match. It is a good thing as it allows to catch errors when the function pointers are really not compatible (like the g_demo.c argument mismatch in the D_MiniLoop function call that this PR fixes)

All of the warnings fixed by this patch is for gcc invocation with no special arguments. So these are default warnings.

Wolf3s commented 4 months ago

merged as co-author.