This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Function Argument Question


Hi, I'm developing a scripting language in which I want to call external
C functions...

The script is invoked by a C program..... but before it is, it sets a
table of addresses that are pointers to the C functions I want to
call...

However, what I need to know how to do is to say at what address the
arguments begin...

If I do something like:
    void func(int a,int b,int c)
    {
        printf("a:0x%x b:0x%x c:0x%x\n",&a,&b,&c);
    }

It prints that a, b, and c are in contiguous memory... So I just need to
say where this memory starts...

Within my scripting language, where I invoke the C function I have
something like:
...
    typedef void (* cfunc)(/*??? something here*/);

    // get the address to the external C function to invoke
    cfunc externalAddress=(cfunc)table.lookup("function name");

    // setup contiguous memory containing the values to the arguments
    void *argMem=malloc(...) ...

    // invoke the external C function
    externalAddress(/*??? something here*/);
...

In the "??? something here" I need to know how to get the argument's
addresses to start at argMem...
    I don't want to be fixed into an exact argument declaration in the C
function.. that'd be easy to do...  I just want the arguments memory to
start somewhere and all arguments to be consecutive (perhaps padded for
bus alignment though).... Is there perhaps a different linkage specifier
I could put infront of the external C functions I'm wanting to call (I
was thinking I may need to do this for the argument order i.e. Pascal
has reversed argument order)..


I've played (and am still playing) around with it, but haven't had much
luck yet...

Any Help?
    Thanks,
        -- Davy




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]