Starting programming in C/C++
  • Order of the Butterfly
    Order of the Butterfly
    Primax
    Posts: 170 from 2021/7/2
    Maybe as a little introduction? (Amiga)

    "Tutorial: Writing an Amiga GUI program in C" written by Edwin van den Oosterkamp:
    https://www.amiga-news.de/en/news/AN-2023-10-00017-EN.html
    AmigaOne X5000 @ 2GHz / 4GB RAM / Radeon X1650 / AmigaOS 4.1 Final Edition / MorphOS 3.17
    Amiga1200 / Blizzard 1230 IV PiStorm32-lite / 128 MB RAM / AmigaOS 3.9
  • »10.12.23 - 04:06
    Profile Visit Website
  • Moderator
    Kronos
    Posts: 2334 from 2003/2/24
    Do you want to begin with C(++) or do you want to begin to use your knowledge of C(++) with MorphOS.

    For the 1st, start with some "for dummies" style of tutorial from the web, plenty to choose, just make sure they don't steer into Windows specific stuff.

    For the later, take the examples in the SDK and experiment.

    At some point you may want to go into GUI and you'd have to choose to either use MUI which is optimal for MorphOS but comes with small compromises for other Amiga systems or you go down the route of using archaic stuff like GadTools which delivers the same level of "not so good" over all systems.
  • »10.12.23 - 06:47
    Profile
  • Paladin of the Pegasos
    Paladin of the Pegasos
    NewSense
    Posts: 1513 from 2012/11/10
    From: Manchester, UK/GB
    @ Papiosaur - try this weblink - via Wayback Machine as it seems it has at least what you wanted to find out, plus a whole lot more! 8-D
    MacMini 1.5GHz,64MB VRAM, PowerBooks A1138/9 (Model 5,8/9),PowerMac G5 2.3GHz(DP), iMac A1145 2.1GHz 20", all with MorphOS v3.18+,Airport,Bluetooth,A1016 Keyboard,T-RB22 Mouse,DVD-RW-DL,MiniMax,Firewire/USB2 & MacOSX 10.4/5
  • »10.12.23 - 12:27
    Profile
  • Yokemate of Keyboards
    Yokemate of Keyboards
    Papiosaur
    Posts: 2242 from 2003/4/10
    From: France
    Quote:

    NewSense a écrit :
    @ Papiosaur - try this weblink - via Wayback Machine as it seems it has at least what you wanted to find out, plus a whole lot more! 8-D


    Thanks NewSense, i have go on your link, get the "Hello World MUI" script, but strangely, i have error during compilation... i get a small window but not complete...

    [EDIT] is there a solution to send the gcc log in a file instead an Ambient Output Window please?
  • »10.12.23 - 14:35
    Profile Visit Website
  • Butterfly
    Butterfly
    AKiLL
    Posts: 91 from 2006/3/6
    From: Naples, Italy
    Hi Papiosaur
    Be careful when using copy and paste from web page to text editor ... You usually import spacing as well ...

    Quote:

    Papiosaur wrote:
    Quote:

    NewSense a écrit :
    @ Papiosaur - try this weblink - via Wayback Machine as it seems it has at least what you wanted to find out, plus a whole lot more! 8-D


    Thanks NewSense, i have go on your link, get the "Hello World MUI" script, but strangely, i have error during compilation... i get a small window but not complete...

    [EDIT] is there a solution to send the gcc log in a file instead an Ambient Output Window please?
  • »10.12.23 - 17:03
    Profile
  • Priest of the Order of the Butterfly
    Priest of the Order of the Butterfly
    Tcheko
    Posts: 536 from 2003/2/25
    From: France
    Quote:

    Papiosaur wrote:
    Do you know why i get errors when i compile this script from Krashan please?

    helloworld-mui.c

    i obtain a buggy window...



    Nothing is helpfull here. What do you mean by buggy window?
    Quelque soit le chemin que tu prendras dans la vie, sache que tu auras des ampoules aux pieds.
    -------
    I need to practice my Kung Fu.
  • »12.12.23 - 10:42
    Profile Visit Website
  • Yokemate of Keyboards
    Yokemate of Keyboards
    Papiosaur
    Posts: 2242 from 2003/4/10
    From: France
    i obtain warnings in the log file and the "app" is "mediating"

    log.txt

    i 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?
  • »12.12.23 - 11:01
    Profile Visit Website
  • Priest of the Order of the Butterfly
    Priest of the Order of the Butterfly
    Tcheko
    Posts: 536 from 2003/2/25
    From: France
    Quote:

    Papiosaur wrote:
    i obtain warnings in the log file and the "app" is "mediating"

    log.txt

    i 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:
    #include <proto/exec.h>


    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.
    Quelque soit le chemin que tu prendras dans la vie, sache que tu auras des ampoules aux pieds.
    -------
    I need to practice my Kung Fu.
  • »12.12.23 - 14:40
    Profile Visit Website
  • Yokemate of Keyboards
    Yokemate of Keyboards
    Papiosaur
    Posts: 2242 from 2003/4/10
    From: France
    Thanks a lot Tcheko for your help!!!

    It work fine now.

    Do you know if Krashan will be ok if i add his sources available on his old website in my project "Easy2Compile", a GUI allowing to compile and execute easiest C source code for MorphOS?

    I tried to contact him via FB and his gmail but no answer for the moment.
  • »12.12.23 - 15:42
    Profile Visit Website
  • Priest of the Order of the Butterfly
    Priest of the Order of the Butterfly
    Tcheko
    Posts: 536 from 2003/2/25
    From: France
    Quote:

    Papiosaur wrote:
    Thanks a lot Tcheko for your help!!!

    It work fine now.

    Do you know if Krashan will be ok if i add his sources available on his old website in my project "Easy2Compile", a GUI allowing to compile and execute easiest C source code for MorphOS?

    I tried to contact him via FB and his gmail but no answer for the moment.


    He lost interest in MorphOS quite some years ago now. I doubt he'll answer. He's back to Amiga stuff only now. I guess you can safely include some of his work. Just do proper credits.
    Quelque soit le chemin que tu prendras dans la vie, sache que tu auras des ampoules aux pieds.
    -------
    I need to practice my Kung Fu.
  • »12.12.23 - 16:33
    Profile Visit Website
  • Yokemate of Keyboards
    Yokemate of Keyboards
    Papiosaur
    Posts: 2242 from 2003/4/10
    From: France
    Quote:

    Tcheko a écrit :
    Quote:

    Papiosaur wrote:
    Thanks a lot Tcheko for your help!!!

    It work fine now.

    Do you know if Krashan will be ok if i add his sources available on his old website in my project "Easy2Compile", a GUI allowing to compile and execute easiest C source code for MorphOS?

    I tried to contact him via FB and his gmail but no answer for the moment.


    He lost interest in MorphOS quite some years ago now. I doubt he'll answer. He's back to Amiga stuff only now. I guess you can safely include some of his work. Just do proper credits.



    I have got an answer from Krashan, he is ok to share his examples of source code, thanks to him!

    Also, I have found these excellent examples on Aminet:

    https://aminet.net/package/dev/mui/Amiga_C_MUI_Examples

    I have contacted the author to adapt them for MorphOS, the package is ready, i just wait his answer.

    I continue to search others examples.
  • »18.12.23 - 03:45
    Profile Visit Website
  • ghh
  • Cocoon
    Cocoon
    ghh
    Posts: 60 from 2017/7/16
    From: Prague
    Here are various unsorted examples in C that I downloaded from the internet.
    http://ghh.8u.cz/friends/amigaCstuff.lha

    For example Thomas Rapp has nice Amiga examples on his site.
    http://thomas-rapp.homepage.t-online.de/examples/index.html
  • »18.12.23 - 14:34
    Profile Visit Website
  • Yokemate of Keyboards
    Yokemate of Keyboards
    Papiosaur
    Posts: 2242 from 2003/4/10
    From: France
    I have adapted some Examples of MUI Sources for Amiga written by emarti Murat Özdemirto for MorphOS (adaptation of the Makefiles to compile on MorphOS, new screenshots from Ambient, some adaptations of some source code to MorphOS).

    Don't hesitate to test them.

    MUI C Examples
  • »18.12.23 - 14:51
    Profile Visit Website
  • ghh
  • Cocoon
    Cocoon
    ghh
    Posts: 60 from 2017/7/16
    From: Prague
    The compiler will usually tell you what to add or edit.
    Add :
    "#include <stdlib.h>"
    "#include <proto/alib.h>"
    Why don't older versions of gcc report errors, but newer versions do?
    I don't know:(
  • »26.12.23 - 14:17
    Profile Visit Website
  • Yokemate of Keyboards
    Yokemate of Keyboards
    Papiosaur
    Posts: 2242 from 2003/4/10
    From: France
    Quote:

    ghh a écrit :
    The compiler will usually tell you what to add or edit.
    Add :
    "#include <stdlib.h>"
    "#include <proto/alib.h>"
    Why don't older versions of gcc report errors, but newer versions do?
    I don't know:(


    Thanks ghh! i fix that and reupload the archive
  • »26.12.23 - 15:57
    Profile Visit Website
  • Yokemate of Keyboards
    Yokemate of Keyboards
    Papiosaur
    Posts: 2242 from 2003/4/10
    From: France
    I have always an error on the source code 10_Slider: "warning: return type defaults to 'int' for line 13 and the 15_VirtualGroup has some errors too after your fix.

    I continue to fix the others.
  • »26.12.23 - 16:13
    Profile Visit Website
  • ghh
  • Cocoon
    Cocoon
    ghh
    Posts: 60 from 2017/7/16
    From: Prague
    Here is the modified version. There are comments "/* NEW */" and "/* OLD */".
    http://ghh.8u.cz/friends/10_slidernew.lha
  • »26.12.23 - 17:51
    Profile Visit Website
  • Yokemate of Keyboards
    Yokemate of Keyboards
    Papiosaur
    Posts: 2242 from 2003/4/10
    From: France
    Quote:

    ghh a écrit :
    Here is the modified version. There are comments "/* NEW */" and "/* OLD */".
    http://ghh.8u.cz/friends/10_slidernew.lha


    Thanks a lot ghh ! I have fixed the 15th alone :-D

    New archive uploaded with fixes in the same link.
  • »26.12.23 - 18:37
    Profile Visit Website