Amiga.org
Amiga computer related discussion => Amiga Software Issues and Discussion => Topic started by: xeron on July 06, 2003, 04:01:36 PM
-
I'm writing some software using GCC 2.95.3. At the moment its all contained in one executable, but later on I'm going to put a lot of the routines in a shared library.
Because of this, a lot of my routines expect taglists. At the moment i'm calling them like this:
struct TagItem mytags[2];
mytags[0].ti_Tag = TAG_SOMETHING_OR_OTHER;
mytags[0].ti_Data = 1234;
mytags[1].ti_Tag =TAG_DONE
mytags[1].ti_Data = 0;
myDoSomethingA( mytags )
Which is quite untidy, and annoying. Is it possible to call the function and specify the tags like you do normally? If so, how?
-
I assume that with "normal" you mean the varargs-functions in the amiga.lib,
which than call the functions in the shared libs.
So, you could do it the same way, but those functions wouldn't fit in a shared lib,
and you would need to put them into a link-lib which would than call the shared lib
with a fixed number of arguments ...
One could also try to define some macros to make calling it easier.
-
RobinC on IRC gave me the answer! All I needed was:
ULONG myDoSomething( ULONG Tag, ... )
{
return myDoSomethingA( (struct TagItem *)&Tag );
}
-
That's not a good idea, because you are making assumptions on how the data is stored on the stack (as LONGs under AOS3/m68k). Instead, if you do not care for using registered arguments, you should use varargs macros that are defined in the includes coming with the compiler, suitable for the machine and the compiler. Here is a short introduction, skip to the varargs paragraph:
varargs (http://zapek.meanmachine.ch/morphos/morphos.html )
-
@Dietmar:
Bear in mind that this is only a stub for my personal testing. Once the routines have been externalised into a library, proper headers will be created.
-
This would be best moved to : "Amiga OS Development" :-P