Re: vMac
- Posted by Robert Craig <rds at EMAIL.MSN.COM> Oct 07, 1998
- 587 views
Robert Craig wrote: >In C, you can't code a call to a routine when you >don't know until run-time how many arguments to pass *or* >what type those arguments are. Hawke' replied: > why is it that for the function parameters in this situation, > you cannot simply have a single pointer as your parameter, > and have that single pointer paramenter at runtime point > to an array of pointers to where each pointer at each array > element was a pointer to a parameter you wanted to pass? Your solution is fine if you are the one writing both the subroutine and the calls to it. The problem in exw is that I have to set up a call to an *arbitrary* C routine in a .DLL. The C routine was written by someone else and it expects to receive a certain number of arguments on the stack, each with a specific type such as int, double, etc. If it isn't done correctly then the program will likely crash. Your Euphoria program tells exw at run-time what the arguments to the C routine should be (see define_c_func()). When you later call c_func(), exw has to set up the call stack in the way that's expected by a WIN32 API call with that many arguments of those types. The call stack is not something that you can play with directly through C. You have to use a bit of assembly code to manipulate it (the PUSH instruction for instance). To the WATCOM C compiler it looks like I'm making a simple call via a function pointer to a 0-argument C function. In fact, I've already pushed your various arguments of various types onto the call-stack via some assembly code, and magically it all works. (Of course I crashed my machine numerous times trying to debug this stuff.) Regards, Rob Craig Rapid Deployment Software http://members.aol.com/FilesEu/