Persistent compiler warnings
  • Priest of the Order of the Butterfly
    Priest of the Order of the Butterfly
    ausPPC
    Posts: 543 from 2007/8/6
    From: Pending...
    This program compiles (with GCC 5) and seems to run as expected but I've been unsuccessful at solving the compiler warnings that follow the source listing.

    Code:
    /*

    > gcc -W -Wall -nostartfiles -noixemul -nostdlib -s -O2 -D__NOLIBBASE__ -DUSE_INLINE_STDARG self_contained_mui.c

    */

    #include <clib/alib_protos.h>

    #include <proto/exec.h>
    #include <proto/dos.h>
    #include <proto/intuition.h>
    #include <proto/muimaster.h>
    #include <dos/dos.h>
    #include <emul/emulinterface.h>
    #include <workbench/startup.h>

    struct ExecBase *SysBase = 0;
    struct Library *DOSBase = 0;
    struct Library *IntuitionBase = 0;
    struct Library *MUIMasterBase = 0;

    ULONG __abox__ = 1;

    ULONG Start(void)
    {
    struct Process *my_process = 0;
    struct Message *ambient_message = 0;
    ULONG return_code = RETURN_OK;

    GETEMULHANDLE
    // gg:os-include/emul/emulinterface.h
    // #define GETEMULHANDLE register struct EmulHandle *MyEmulHandle __asm("r2");

    SysBase = MyEmulHandle->SuperHandle->GlobalSysBase;

    my_process = (struct Process *) FindTask(0);

    if(my_process->pr_CLI)
    {
    if((DOSBase = OpenLibrary((STRPTR) "dos.library", 0)))
    {
    PutStr("Press Ctrl-C or the 'Hello World' window close button to exit.n");
    CloseLibrary(DOSBase);
    }
    else return_code = RETURN_FAIL;
    }
    else
    {
    WaitPort(&my_process->pr_MsgPort);
    ambient_message = GetMsg(&my_process->pr_MsgPort);
    }

    if((IntuitionBase = OpenLibrary((STRPTR) "intuition.library", 0)) &&
    (MUIMasterBase = OpenLibrary((STRPTR) "muimaster.library", 0)))
    {
    Object *App, *Win;

    App = MUI_NewObject(MUIC_Application,
    MUIA_Application_Window, (Win = MUI_NewObject(MUIC_Window,
    MUIA_Window_Title, (ULONG) "Hello World",
    MUIA_Window_RootObject, MUI_NewObject(MUIC_Group,
    MUIA_Group_Child, MUI_NewObject(MUIC_Text,
    MUIA_Text_Contents, (ULONG) "Hello world!", TAG_END),
    TAG_END),
    TAG_END)),
    TAG_END);

    DoMethod(Win, MUIM_Notify, MUIA_Window_CloseRequest, TRUE, App, 2,
    MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit);

    set(Win, MUIA_Window_Open, TRUE);

    ULONG signals = 0;

    while(DoMethod(App, MUIM_Application_NewInput, &signals) != (ULONG) MUIV_Application_ReturnID_Quit)
    {
    signals = Wait(signals | SIGBREAKF_CTRL_C);
    if(signals & SIGBREAKF_CTRL_C) break;
    }

    set(Win, MUIA_Window_Open, FALSE);

    MUI_DisposeObject(App);

    CloseLibrary(IntuitionBase);
    CloseLibrary(MUIMasterBase);
    }
    else return_code = RETURN_FAIL;

    if(ambient_message)
    {
    Forbid();
    ReplyMsg(ambient_message);
    }

    return(return_code);
    }


    Code:
    Ram Disk:> gcc -W -Wall -nostartfiles -noixemul -nostdlib -s -O2 -D__NOLIBBASE__ -DUSE_INLINE_STDARG self_contained_mui.c
    self_contained_mui.c: In function 'Start':
    self_contained_mui.c:58:9: warning: initialization makes integer from pointer without a
    cast [-Wint-conversion]
    App = MUI_NewObject(MUIC_Application,
    ^
    self_contained_mui.c:58:9: note: (near initialization for '_tags[1]')
    self_contained_mui.c:58:9: warning: initialization makes integer from pointer without a
    cast [-Wint-conversion]
    self_contained_mui.c:58:9: note: (near initialization for '_tags[3]')
    In file included from /gg/os-include/proto/muimaster.h:19:0,
    from self_contained_mui.c:12:
    self_contained_mui.c:59:29: warning: initialization makes integer from pointer without a cast [-Wint-conversion]
    MUIA_Application_Window, (Win = MUI_NewObject(MUIC_Window,
    ^
    self_contained_mui.c:59:29: note: (near initialization for '_tags[1]')
    In file included from self_contained_mui.c:7:0:
    self_contained_mui.c:68:62: warning: initialization makes integer from pointer without a cast [-Wint-conversion]
    DoMethod(Win, MUIM_Notify, MUIA_Window_CloseRequest, TRUE, App, 2,
    ^
    self_contained_mui.c:68:62: note: (near initialization for '_tags[3]')
    self_contained_mui.c:75:50: warning: initialization makes integer from pointer without a cast [-Wint-conversion]
    while(DoMethod(App, MUIM_Application_NewInput, &signals) != (ULONG) MUIV_Application_ReturnID_Quit)
    ^
    self_contained_mui.c:75:50: note: (near initialization for '_tags[1]')
    Ram Disk:>
    PPC assembly ain't so bad... ;)
  • »31.12.16 - 01:21
    Profile Visit Website
  • MorphOS Developer
    jacadcaps
    Posts: 2972 from 2003/3/5
    From: Canada
    The warnings are de facto correct. You need to either disable them or cast pointers on a taglist.

    So MUIA_Window_RootObject, MUI_NewObject(MUIC_Group needs an (ULONG) cast before MUI_NewObject. Or a nicer IPTR cast.
  • »31.12.16 - 03:29
    Profile Visit Website
  • Priest of the Order of the Butterfly
    Priest of the Order of the Butterfly
    ausPPC
    Posts: 543 from 2007/8/6
    From: Pending...
    Thank you - that put me on the right track. I got this to compile without warnings.

    Code:
    /*

    > gcc -W -Wall -nostartfiles -noixemul -nostdlib -s -O2 -D__NOLIBBASE__ -DUSE_INLINE_STDARG self_contained_mui.c

    */

    #include <clib/alib_protos.h>

    #include <proto/exec.h>
    #include <proto/dos.h>
    #include <proto/intuition.h>
    #include <proto/muimaster.h>
    #include <dos/dos.h>
    #include <emul/emulinterface.h>
    #include <workbench/startup.h>

    struct ExecBase *SysBase = 0;
    struct Library *DOSBase = 0;
    struct Library *IntuitionBase = 0;
    struct Library *MUIMasterBase = 0;

    ULONG __abox__ = 1;

    ULONG Start(void)
    {
    struct Process *my_process = 0;
    struct Message *ambient_message = 0;
    ULONG return_code = RETURN_OK;

    GETEMULHANDLE
    // gg:os-include/emul/emulinterface.h
    // #define GETEMULHANDLE register struct EmulHandle *MyEmulHandle __asm("r2");

    SysBase = MyEmulHandle->SuperHandle->GlobalSysBase;

    my_process = (struct Process *) FindTask(0);

    if(my_process->pr_CLI)
    {
    if((DOSBase = OpenLibrary((STRPTR) "dos.library", 0)))
    {
    PutStr("Press Ctrl-C or the 'Hello World' window close button to exit.n");
    CloseLibrary(DOSBase);
    }
    else return_code = RETURN_FAIL;
    }
    else
    {
    WaitPort(&my_process->pr_MsgPort);
    ambient_message = GetMsg(&my_process->pr_MsgPort);
    }

    if((IntuitionBase = OpenLibrary((STRPTR) "intuition.library", 0)) &&
    (MUIMasterBase = OpenLibrary((STRPTR) "muimaster.library", 0)))
    {
    Object *App, *Win;

    App = MUI_NewObject(MUIC_Application,
    MUIA_Application_Window, (IPTR) (Win = MUI_NewObject(MUIC_Window,
    MUIA_Window_Title, (ULONG) "Hello World",
    MUIA_Window_RootObject, (IPTR) MUI_NewObject(MUIC_Group,
    MUIA_Group_Child, (IPTR) MUI_NewObject(MUIC_Text,
    MUIA_Text_Contents, (ULONG) "Hello world!", TAG_END),
    TAG_END),
    TAG_END)),
    TAG_END);

    DoMethod(Win, MUIM_Notify, MUIA_Window_CloseRequest, TRUE, (ULONG) App, 2,
    MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit);

    set((APTR) Win, MUIA_Window_Open, TRUE);

    ULONG signals = 0;

    while(DoMethod(App, MUIM_Application_NewInput, (ULONG) &signals) != (ULONG) MUIV_Application_ReturnID_Quit)
    {
    signals = Wait(signals | SIGBREAKF_CTRL_C);
    if(signals & SIGBREAKF_CTRL_C) break;
    }

    set((APTR) Win, MUIA_Window_Open, FALSE);

    MUI_DisposeObject(App);

    CloseLibrary(IntuitionBase);
    CloseLibrary(MUIMasterBase);
    }
    else return_code = RETURN_FAIL;

    if(ambient_message)
    {
    Forbid();
    ReplyMsg(ambient_message);
    }

    return(return_code);
    }
    PPC assembly ain't so bad... ;)
  • »31.12.16 - 09:21
    Profile Visit Website