|
| |
| |
| |
|
|
|
Online members:
kas1e 24 min(s) ago Georg 55 min(s) ago
12 guests are online.
You are an Anonymous user. You can register for free by clicking here. |
|
|
| |
| |
| |
| |
| |
| |
UtilityBase needs your
help!
How to write portable code for Amiga (english) by corto Link: How to write portable code for Amiga (english) (pdf)
This document explains the specificities of each system or compiler. It gives information to program in a portable way. Write once, compile everywhere !
The main chapters are :
1. Includes : understand and manage these files, helping to obtain an organization for several compilers
2. OS specificities : define usage for conditional compilation, OS4 interfaces, amiga.lib and DoSuperNew management, various topics (tasks, memory, ...)
3. Compiler specificities and how to handle them with SDI_headers, hook management
4. Resources : documentation, SDK, support, ...
Please report bugs or questions.
|
|
| Last poster |
Message |
|
Posted: 2006-02-16 00:04
Interesting PDF.
Few notes:
Alignment issues. On PPC ULONGs are automatically aligned to ULONG boundary, i.e.
struct foobar
{
 UWORD foo;
 ULONG bar;
};
would be 8 bytes on PPC but 6 bytes on 68k. If it must be exactly same on 68k and PPC either use #pragma pack():
#pragma pack(2)
struct foobar
{
 UWORD foo;
 ULONG bar;
};
#pragma pack()
This is important issue especially when porting larger programs from 68k. If in doubt use #pragma pack(2) everywhere and sort it out later when better knowledge over it... performance loss is minimal anyway.
Another thing is SDI_stdarg.h. I dont think it works on AROS... |
|
Posted: 2006-02-16 16:51
Oops ! You're right, I forgot the alignment issue ... I will wait for other comments before updating the document.
Thank you for your compliment, itix !
About portability, we may add a part dedicated to SDL ? This well known lib is often used for Amiga projects now. |
|
Posted: 2006-02-16 23:09
SDL always same was it OS3, OS4, MOS or AROS... do you have something specific in mind? |
|
Posted: 2006-02-17 14:24
I have nothing specific in mind ... there could have differences in compilation commands and mainly in features (joystick support, OpenGL, ...). But it's not really the goal of this document. What you wrote about alignment issues is far more important.
For those who could be interested in my portable Amiga developments, I recently opened my blog :) |
|
Posted: 2006-02-17 17:31
Joystick internals are hidden behind SDL API and depending on SDL implementation it either works or not... In MOS it is based on lowlevel.library and on OS4 on amigainput.library but to SDL program it doesnt make difference. In practise all issues with SDL are porting issues from other OS'es and that is whole new matter...
Btw there is no libamiga.a in MorphOS SDK but it is libabox.a and libaboxstubs.a. In VBCC it is libamiga.a still. Anyway it doesnt matter because they are automatically linked in and it is not necessary include them on the linking stage. |
|
Posted: 2008-11-17 14:36
@itix
I found out this alignment thing the hard way when attempting to recreate a 68k system library for OS4 PPC and it just kept crashing at these strange offsets. Very annoying! |
|
Posted: 2009-06-29 04:58
|
|
Posted: 2009-06-29 16:34
@manola
And what's this ringtone crap got to do with alignments? |
|
Posted: 2009-06-29 17:47
@hypex: do you really expect an answer? |
|
Posted: 2009-06-30 15:46
@wawa
No, just like to voice an opinion.
Hey you answered, thanks! That makes it all worth while! :-D
The profile looked more together than most. Should we spam the guy? ;-) |
|
Posted: 2010-07-18 08:26 · Edited by: Minuous
It's a pity this document doesn't go into what the differences are between the various flavours of include file. Eg. OpenURL has 9: clib, defines, inline, inline4, interfaces, libraries, ppcinline, proto, pragmas. |
|
Posted: 2010-07-18 11:44 · Edited by: Minuous
OK, I'm currently using:
#include <libraries/openurl.h> #include <proto/openurl.h>
and it doesn't work, my porter is getting this:
amiga3.o: In function `openurl': /Work/SDK/Progetti/Source/amiga3.c:6216: undefined reference to `URL_Open' make: *** [../AmiArcadia.debug] Error 1
If I swap the order of the two files will this fix the problem, or is it something else? |
|
Posted: 2010-07-18 08:56
@Minuous You should read the file Migration Guide.pdf from the OS4 SDK.
These include files are compiler specific. For the two OS4 compilers (GCC and VBCC) only include the proto files and any other files that may be required.
For example: #include <proto/intuition.h> #include <intuition/intuition.h> #include <intuition/screens.h> |
|
Posted: 2010-07-18 12:27
If you don't use the __USE_INLINE__ define you have to write IOpenURL->URL_Open() |
|
Posted: 2010-07-21 23:53
Minuous I already answered on this one to Samir the day he asked me (it was last week) just be sure to use complete *official* includes of OpenURL and be sure to remove inclusion of <clib/openurl_protos.h> at the beginning of amiga3.c it will then compile out of the box and run smoothly.
To answer you under AmigaOS4 only "interfaces" and "inline4" drawers are important (and used) by GCC (don't know about vbcc). Interfaces contains files defining the library interface (structure and name) while inline4 is used when compiling with __USE_INLINE__ preprocessor symbol defined it activate OS 3.x syntax compatibility (i.e. direct use of OpenScreen() rather than IIntuition->OpenScreen() for example). |
|
Posted: 2010-07-23 10:40
itix: In VBCC it is libamiga.a still. Anyway it doesnt matter because they are automatically linked in and it is not necessary include them on the linking stage. That's not entirely correct. vbcc doesn't automatically link with libamiga.a. Normally you won't notice, because an #include <proto/xyz.h> will use assembler inlines to call OS functions, instead of using a stub function from libamiga. But you will notice when calling real libamiga functions, like DoMethod(), BeginIO(), etc. |
|
|
|