Welcome, Guest. Please login or register.

Author Topic: Taglist question  (Read 1527 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline xeronTopic starter

  • Hero Member
  • *****
  • Join Date: Mar 2002
  • Posts: 2533
    • Show only replies by xeron
    • http://www.petergordon.org.uk
Taglist question
« 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?
Playstation Network ID: xeron6
 

Offline Kronos

  • Resident blue troll
  • Hero Member
  • *****
  • Join Date: Feb 2002
  • Posts: 4017
    • Show only replies by Kronos
    • http://www.SteamDraw.de
Re: Taglist question
« Reply #1 on: July 06, 2003, 04:12:05 PM »
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.
1. Make an announcment.
2. Wait a while.
3. Check if it can actually be done.
4. Wait for someone else to do it.
5. Start working on it while giving out hillarious progress-reports.
6. Deny that you have ever announced it
7. Blame someone else
 

Offline xeronTopic starter

  • Hero Member
  • *****
  • Join Date: Mar 2002
  • Posts: 2533
    • Show only replies by xeron
    • http://www.petergordon.org.uk
Re: Taglist question
« Reply #2 on: July 06, 2003, 05:19:30 PM »
RobinC on IRC gave me the answer! All I needed was:


ULONG myDoSomething( ULONG Tag, ... )
{
  return myDoSomethingA( (struct TagItem *)&Tag );
}

Playstation Network ID: xeron6
 

Offline Dietmar

  • Full Member
  • ***
  • Join Date: Nov 2002
  • Posts: 220
    • Show only replies by Dietmar
    • http://devplex.awardspace.biz
Re: Taglist question
« Reply #3 on: July 06, 2003, 05:40:12 PM »
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
 

Offline xeronTopic starter

  • Hero Member
  • *****
  • Join Date: Mar 2002
  • Posts: 2533
    • Show only replies by xeron
    • http://www.petergordon.org.uk
Re: Taglist question
« Reply #4 on: July 06, 2003, 05:54:52 PM »
@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.
Playstation Network ID: xeron6
 

Offline iamaboringperson

  • Hero Member
  • *****
  • Join Date: Jun 2002
  • Posts: 5744
    • Show only replies by iamaboringperson
Re: Taglist question
« Reply #5 on: July 06, 2003, 11:09:25 PM »
This would be best moved to : "Amiga OS Development" :-P