bmx-ng / brl.mod

BlitzMax Runtime Libraries, for BlitzMax NG.
12 stars 11 forks source link

GCC 14.2 compilation issues/errors (appstub.mod, io.mod ...) because of now required casts #332

Open GWRon opened 1 month ago

GWRon commented 1 month ago

So I tried to compile on ArchLinux running a GCC 14.2. (required an install of webkit2gtk to get MaxIDE running first).

Compiling a simple sample for now:

SuperStrict
Framework Brl.StandardIO

print "Hello World"

first error popping up is about some implicit declaration (because it does not find the function)

/home/ronny/Downloads/BlitzMax/mod/brl.mod/appstub.mod/appstub.linux.c: In Funktion »bmx_process_vm_readv«:
/home/ronny/Downloads/BlitzMax/mod/brl.mod/appstub.mod/appstub.linux.c:38:25: Fehler: Implizite Deklaration der Funktion »process_vm_readv«; meinten Sie »bmx_process_vm_readv«? [-Wimplicit-function-declaration]
   38 |         size_t result = process_vm_readv(pid, &local, 1, &remote, 1, 0);
      |                         ^~~~~~~~~~~~~~~~
      |                         bmx_process_vm_readv

I simply prepended #define _GNU_SOURCE to "brl.mod/appstub.mod/appstub.linux.c" to fix that.

next error is something which thrown a lot (I for now stopped trying to "fix" things as I am not sure if it is even correct what I do - or if it just removes the warning but breaks the code :D)

Sample error:

/home/ronny/Downloads/BlitzMax/mod/brl.mod/appstub.mod/debugger.stdio.glue.c: In Funktion »bmx_debugger_DebugDeclNext«:
/home/ronny/Downloads/BlitzMax/mod/brl.mod/appstub.mod/debugger.stdio.glue.c:33:31: Fehler: Rückgabe von »char *« aus einer Funktion mit inkompatiblem Rückgabetyp »struct BBDebugDecl *« [-Wincompatible-pointer-types]
   33 |         return ((char *)decl) + sizeof(struct BBDebugDecl);
      |                ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~

Which I fixes with:

struct BBDebugDecl * bmx_debugger_DebugDeclNext( struct BBDebugDecl * decl ) {
    //OLD: return ((char *)decl) + sizeof(struct BBDebugDecl);
    return (struct BBDebugDecl *)(((char *)decl) + sizeof(struct BBDebugDecl));
}

As said similar needs to be done in other files (eg blitz_app.c):

    //OLD: bbGCStackTop=ebp+28;
    bbGCStackTop = (void **)(ebp + 28);

It also affects stuff like physfs (io.mod) - but I think there the error can be fixed differently - there the first element of a char array pointer was tried to be assigned to a char pointer. Without the ampersand C should (according to the internet :D) already return the first element (so a char pointer here):

int bmx_PHYSFS_setRoot(BBString * archive, BBString * subdir) {
    char abuf[1024];
    size_t len = 1024;
    bbStringToUTF8StringBuffer(archive, abuf, &len);

    char sbuf[1024];
    size_t slen = 1024;

    char * sd = 0;
    if (subdir != &bbEmptyString) {
        bbStringToUTF8StringBuffer(subdir, sbuf, &slen);
        //OLD: sd = &sbuf;
        //not needed to &... because name of arrays already point to first element
        sd = sbuf;
    }

    return PHYSFS_setRoot(abuf, sbuf);
}

Is it worth to try "fixing it on my own" or is it not correct what I am doing here? Maybe just adding the compiler flag to ignore these things should do (plus the #define-line ...)

GWRon commented 1 month ago

adding "-Wno-incompatible-pointer-types" removed a lot of the clutter and made it compile". For now I simply added it into make.bmk (after the disable warnings line):

    # disable warnings ?
    if %CC_WARNINGS% == "" then
        opts = opts .. " -w"
    end
    #only usable for C/ObjC but not C++.
    if ext == "c" then 
      opts = opts .. " -Wno-incompatible-pointer-types -Wno-implicit-function-declaration"
    end

As it is only available after GCC 5 I am not sure if we need to take care of it with some GCC-Version check ... Also it cannot be used for C++ - compilations (spits out some warnings there). I also disabled the implicit function declaration warning which skips requiring the change (gnu source...)

GWRon commented 1 month ago

The bbThreadRegister-call n "sdl.mod/SDL/src/thread/SDL_thread.c SDL_Runthread" also does some conversion it does not like.

    /* register with BlitzMax */
    BBThread * bbThread = bbThreadRegister(SDL_ThreadID());

I supressed it with -Wno-int-conversion (in the same line) albeit I am feeling it should be handled there "directly" (as it is a modification of some 3rd party file anyway).

GWRon commented 2 weeks ago

the gnu_source-part is now added via 0ed5db03fd60840c63087bf92b9bee7ceed4ea87

debugger-issue resolved and thread-casting resolved by adding a typedef/custom "type" in 120dc1f3ffeb7175d90aea2b615bac320195cb19 and https://github.com/bmx-ng/sdl.mod/commit/347575c94ef00f511cdf756a9469df49e94026b7