Priest of the Order of the Butterfly
Posts: 534 from 2003/2/25
From: France
Quote:Papiosaur wrote:
i obtain warnings in the log file and the "app" is "mediating"
log.txti get a 68k exception in Task 0x1d442cf8 <Backgroud CLI [ram:helloworld-mui]> when i launch the executabe
The window has no title, no resizable gadget like the screenshot from MorphOS-Library and quit button don't work:
Hello World MUI[EDIT] Is it possible to get the informations about styled characters of the gcc output in the output file please?
Ok. A bit more usefull to help.
Tried to compile the crap and indeed, it badly explodes.
1. Fixing the warnings
If you have such warnings, it means that the compiler don't know the name of the function. An easy way to find out what missing include you need is to do the following in a shell:
Code:
1.> cd GG:os-include
1.> grep -r FunctionName *
This will return possible candidates for inclusion.
Add the following to the beginning of the file
Fixing Wait() warning:
Code:
Fixing DoMethod() warning:
Code:
#include <clib/alib_protos.h>
2. Fixing the horrible explosion
Haha. This one is my favorite here. What a fun brainfart!
In build_gui() function call, this one is supposed to return an Object* (a pointer to a BOOPSI object) but there is no damn return statement in the function body.
Object *App is declared as a global variable at the top of the file. This one get assigned when build_gui() is called inside the function body.
*BUT* when the function returns, in the allocation sequence in main(), we have a nice
Code:
if (App = build_gui())
{
...
}
which overwrite the Object *App value with a probably somewhat but not totally random value (because of the missing return statement in build_gui() function). The thing manage to open the window with a broken pointer. MUI amazes me everyday.
Obvious fix is simply adding a return statement in the build_gui() function call.
This thing probably worked just fine when it was written (2010!) with older GCC (we were running 2.95 at the time I think). In this case, the returned value by build_gui() function would probably been the right *App value... by pure luck!
Lesson of the day:
When compiling things, add -Wall option to your compilation command. For this example:
Code:
gcc -noixemul -Wall -o hello mui.c
This would have directly hinted at the problem in the code.
Hope this help. Happy coding.