Software Archive
Read-only legacy content
17061 Discussions

subroutine argument count

james1
Beginner
961 Views
I'd like a way of returning the argument count to the current procedure. On OVMS IARGCOUNT() does this nicely, however other architectures do not support an argument count in the call frame. Therefore I was wondering if there is some intrinsic property that would return the quantity of formal arguments. This could of course be hard coded, but as the compiler has full knowledge of this value it would be more foolproof.

James
0 Kudos
7 Replies
Steven_L_Intel1
Employee
961 Views
There isn't an intrinsic to return the number of arguments, which is either fixed or unknown, depending on the call mechanism.

Steve
0 Kudos
james1
Beginner
961 Views
Didn't think so...any possibility of implementing IARGCOUNT() for CVF, having it return the number of formal arguments rather than actual arguments so that the intrinsic would be available on both platforms? While the meaning would be a little different, one could argue that the only legitamite argument count under Windows is the format parameter count anyway?

James
0 Kudos
Steven_L_Intel1
Employee
961 Views
Note that only for STDCALL interfaces can the compiler know the argument count - for the C interface, there is no information at all. I'm having a hard time understanding how this would be useful to you, given that the caller always has to pass the same number of arguments.

Steve
0 Kudos
james1
Beginner
961 Views
Sorry for the delay. This is because as a matter of course the iargmask routine is used in a large number of routines on the OVMS system, this works great, one just needs to know the maximum bit number to check. With OVMS you can check IARGCOUNT to figure that out and there is no code maintenance hassle when one adds a parameter. By porting this to Win IARGMASK still works and whether or not an interface is available to the caller optional arguments may be determined. All that is required is a placeholder actual parameter for each specified formal parameter and all is well. All that is missing is a argument count, or next best thing, maximum argument count since Win cannot handle variable argument lists in the first place. The alternative is simply to hard code the formal parameter count in each routine, but this is not as elegant and possibly prone to more errors. I hope that makes sense!

James
0 Kudos
Steven_L_Intel1
Employee
961 Views
Interesting, but this is really specific to your application - iargmask is not something we supply on VMS either.

Steve
0 Kudos
james1
Beginner
961 Views
Sorry for the delay. This is because as a matter of course the iargmask routine is used in a large number of routines on the OVMS system, this works great, one just needs to know the maximum bit number to check. With OVMS you can check IARGCOUNT to figure that out and there is no code maintenance hassle when one adds a parameter. By porting this to Win IARGMASK still works and whether or not an interface is available to the caller optional arguments may be determined. All that is required is a placeholder actual parameter for each specified formal parameter and all is well. All that is missing is a argument count, or next best thing, maximum argument count since Win cannot handle variable argument lists in the first place. The alternative is simply to hard code the formal parameter count in each routine, but this is not as elegant and possibly prone to more errors. I hope that makes sense!

James
0 Kudos
james1
Beginner
961 Views
Whoops, please substitute IARGPTR for IARGMASK in the above.

James
0 Kudos
Reply