Jump to content
  • Advertisement
Sign in to follow this  
Cosmy

Register function with arguments

This topic is 3119 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have this: r = pEngine->RegisterGlobalFunction("void printf(string &format, ...)", asFUNCTION(as_printf), asCALL_CDECL); assert(r >= 0); But when i call "printf" function the compiler give me this error: Invalid configuration I know because the compiler give me error, because i used "..." for args. Help me :(

Share this post


Link to post
Share on other sites
Advertisement
AngelScript doesn't support variable argument list, therefore you can't define a printf type function. Instead you can create something like cout using the << operator.

For an example of this you can take a look at my Output class:
http://git.jeremyh.net/eScript/tree/Source/Core/Stdlib/Output.cpp & http://git.jeremyh.net/eScript/tree/Include/Core/Stdlib/Output.h.

The REG_OBJ_SINGLETON, REG_OBJ_METHOD, etc are macros to make things easier and are defined in:
http://git.jeremyh.net/eScript/tree/Include/Core/Engine.h.

Share this post


Link to post
Share on other sites
droz is correct.

AngelScript currently doesn't support variable arguments. I have plans to add this support in a future version, though it will not be natively compatible with how it works in C/C++ as that is not typesafe. Instead it will be supported through the generic calling convention, where the C++ application will be able to query the number of arguments and the types of them dynamically when the function is called.



Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!