May 26, 2024, 03:20:45 PM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


using function templates

Started by cbrescia, August 20, 2008, 05:30:04 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

cbrescia

Does anybody knows how to check out whether a subroutine exists or not. I've tried  &name, but the compiler complains. I think that in the case you are working with pointers to functions, a sub is a value which can be assigned or not. It might be &name = 0 or TYPEOF(name) = @UNDEFINED? to verify at run time the existence or non existence of a name? It would be handy if writing events which can be or not defined from a function template. But in that case the compiler must emit a warning not an error.

Regards

Ionic Wind Support Team

Hello,

You are using a compiler, so subroutine names don't exist at runtime, they are only addresses.  Unless it is a global subroutine in which case a COFF record exists for the name, but that is only for the linker to resolve the address of the subroutine.  Which is the same as the C language would do it.

'&' when used in this context means "address of" and if the subroutine doesn't exist then of course the compiler will give you an error as it cannot resolve the address of a non existent function.

Paul Turley
Ionic Wind Software
Ionic Wind Support Team

cbrescia

OK, Then, I could try different approaches.
One is someway cumbersome but it depends if a function label can be exported to the same executable program as in dlls, by means of EXPORT.
The other involves OOP Virtual tables because I need to check out if a member function is implemented. I donÂÃ,´t know if the & operator works in that case, something like &actualobject::somefunction, does it get a NULL address if it is not implemented?.

Regards