Start coding on the AmigaOS4

7 posts / 0 new
Last post
TheSLASH
TheSLASH's picture
Offline
Last seen: 12 years 10 months ago
Joined: 2011-12-27 00:50
Start coding on the AmigaOS4

I have been coding C++ and C# for some years now, but not that much C++ lately, and I'm trying to follow the most simple guides I can find, and try to open a standard Window, but I got errors all over, and it may be different to code on the Amiga compared to PC/Windows/Linux, as what I heard the Amiga don't realy support C++ to the fully and most people using C, I can live with that.

I'm using CodeBech, and get error like this:

warning: implicit declaration of function 'OpenLibrary'

etc.

And what's these "proto" file, have never seen them on the PC. :) I have tried to find a good way to read the AutoDoc's, but haven't found one..

kas1e
kas1e's picture
Offline
Last seen: 3 months 5 days ago
Joined: 2010-11-30 15:30
as what I heard the Amiga


as what I heard the Amiga don't realy support C++ to the fully and most people using C, I can live with that.

Most of the games and apps which i port from unix to aos4 are C++. MUIOWB browser also C++/C. As i know C++ have some bugs currently, but those ones can be workorounded and they happens in rare situations. You maybe never will meet with them. One difference beetwen let's say GCC on unix, its that our one builds as single-threaded. And as far as i can tell there is no other limitations. All those constuctors/destructors and other crap. Sources of our gcc are avaialbe at adtools.sourceforge.net, so if you will have real interest you can dig in anytime :)


warning: implicit declaration of function 'OpenLibrary'
etc.
And what's these "proto" file, have never seen them on the PC. :) I have tried to find a good way to read the AutoDoc's, but haven't found one..

If you want to start with "PC" way, you can just use classic "libc" and some 3d party toolkits like SDL, OpenGL, Allegro and so on. I.e. you can just use the same (most of them) posix and ansi c functions. But of course no directx or gdi here :)

But if you want to use "real amigaos4 fucntions" (which you use in end anyway, because when you use libc, they just stubs for real amiga functions in end), you can use them, and then you need all those "proto" files. You can think (for begining) about them as "new toolkit". Want aos4 fucntions - use proto.

For example your OpenLibrary function are from exec.library. And so, to have it works in your programm, you should #include <proto/exec.h> and then you can use it.

You also can follow few ways with amiga-specific functions (like for compatibility with old code from os3 add -D__USE_INLINE__) , but by default you will be force to new way already, and you not need to worry about.

All what you need to know its that logic of real aos4 programms are:

-- open library
-- open interface

-- use functions of library, do all the code you need

-- drop interface
-- close library

Nothing hard in general. Just you need to check some docs in the SDK directory and if something is unclear ask here.

TheSLASH
TheSLASH's picture
Offline
Last seen: 12 years 10 months ago
Joined: 2011-12-27 00:50
I believe there's a lot to

I believe there's a lot to learn here, maybe it's this step for all kind of OS and there's no easy portabillity betweens different OS, especially the GUI parts. I have search a bit here, but couldn't find any begginers guide with simple things like a Window/Screen, and the example I found somewhere (?) was a bit OS4 (as it used these proto-stuff), but not 100% as it needed the extra Compiler Switches (-D__USE_INLINE__, in CodeBench) to accept the code, and I want to use the new "future prof way". I would be happy if someone could point me some links.

I did also have to modify the "MyText.IText = (char*)"Hello Intuition!";" with this "(char*) or it complaint about:

warning: assignment discards qualifiers from pointer target type

..and the textoutput was placed half up onto the Windowbar, din't looked good at all, looked like a hack, and it's position where 0, 0, so it should be fine, and I don't have any GUI-hacks what I know about to trash things like this.

I have also search in the SDK directory for some simple examples with standard amiga GUI but couldn't find any. And I have a memory that examples like that existed in 3.x SDK, but I could be wrong.

kas1e
kas1e's picture
Offline
Last seen: 3 months 5 days ago
Joined: 2010-11-30 15:30
I believe there's a lot to


I believe there's a lot to learn here, maybe it's this step for all kind of OS and there's no easy portabillity betweens different OS, especially the GUI parts

Of course. All the native-gui code are different everythere. Be it gdi, or xwindow, or reaction, or mui.


I have search a bit here, but couldn't find any begginers guide with simple things like a Window/Screen

As this site does not have "articles" section, it can be a bit misleading that "blog posts" are most of time is real articles. So, if you press on the main page in the blog-posts for "more", and swith on the first page, you will find reaction based examples of helloworld (i.e. opening of reaction based window, and so on). If you in interest in gui coding, then you should also read here Trixie's and Rigo's blogposts (I write mail to Walkero (admin of that site) to make a one more section called "articles", to avoid that misleading, but dunno if and when he will add it).

Aos4 also have support of one more widely used gui toolkit - MUI (i.e. Reaction are official in aos4, but MUI are come as some 3d party contribution, but also works fine). There is a lot of mui examples and docs fying around, and if you will in interest in mui exactly, ask here i will bring you few links.


but not 100% as it needed the extra Compiler Switches (-D__USE_INLINE__, in CodeBench) to accept the code

If it was native aos4 example, then -D__USE_INLINE__ not need it. That switch mostly used when you tryint to port stuff from os3 to os4, or, just when you programming in "os3" way (i.e. without IInterface-> stuff. That swith just cover itnerface stuff automatically).

Anyway, just check example from Methos's article in first blog-posts.

TheSLASH
TheSLASH's picture
Offline
Last seen: 12 years 10 months ago
Joined: 2011-12-27 00:50
I have seen these blogs, and

I have seen these blogs, and they are sure usefull when I go for these parts. I read about ReAction on Wikipedia and it's the "new" official GUI for AOS4, but it also said it's using intuition as a base, and my first intention is not to build a heavy GUI program, and to start without GUI.. Ok, the Menu's (if I add that) is probably some type of GUI, but would like to create small resourcefriendly programs and learn the basics/base of what's everything else is built upon. For sure I will have to go for ReAction or MUI one day, and probably learn it all again, and if I understand it right is Cairo also a GUI addon with 2D (3D accelerated) graphics.

jaokim
jaokim's picture
Offline
Last seen: 1 month 2 weeks ago
Joined: 2011-06-02 15:27
One difference beetwen let's

One difference beetwen let's say GCC on unix, its that our one builds as single-threaded.

What exactly does this mean? I have a C++ project with different processes in them, communicating using ordinary messages, and it seems to work fine.
I have heard something about C++ exceptions not functioning correctly in threads (or rather, processes), but I did some testing, and that also seems to work.

kas1e
kas1e's picture
Offline
Last seen: 3 months 5 days ago
Joined: 2010-11-30 15:30
@jaokim What exactly does

@jaokim


What exactly does this mean? I have a C++ project with different processes in them, communicating using ordinary messages, and it seems to work fine. I have heard something about C++ exceptions not functioning correctly in threads (or rather, processes), but I did some testing, and that also seems to work.

I will better just copy+paste some answers about, from Hans and Ssolie:

From Hans:


The problem is not running multiple threads itself, but what should happen when you use C++ features such as exceptions. For example, what should happen if an exception occurs in one thread, but needs to be handled in another? What mechanism should be used to handle such a case?

C++ can't stop you from starting new threads/tasks but, without C++ multi-threading support, you need to respect the limitations.

From SSolie:


Threading in C and C++

It is very important to note that both C and C++ (current standard) do not specify nor directly support threading. This may come as a surprise to many programmers that have been developing threading applications in both C and C++ for many years.

Since there is no official standard, threading has always been system dependent and several threading standards have come and gone over the years. One popular threading standard is called POSIX Threads or pthreads for short.

AmigaOS supports a subset of the pthreads standard. It is implemented as a standard shared library with both static and dynamic link interfaces. The dynamic link interface is an Amiga shared object named libpthread.so. The static link interface is available in both newlib and clib2 flavours. These link libraries are just thin wrappers for the underlying pthreads.library.

With C the threading issue is relatively simple and GNU GCC supports a memory model which supports threading so there is little for an Amiga programmer to worry about. This is true for all platform GCC supports.

The C++ programming language is a more complicated issue. The current GCC compiler implementation does not support threading on AmigaOS. This can be verified with the g++ -v command. The output of this command will specify what threading model is supported. On AmigaOS it currently states:

Thread model: single

This means threading is not supported. As a consequence, C++ exceptions and the RTTI feature will not function correctly in the presence of threads. Both features are optional in C++ but highly desirable as well. The Amiga programmer needs to make some tough decisions in this case.

Log in or register to post comments