albertodemichelis / squirrel

Official repository for the programming language Squirrel
http://www.squirrel-lang.org
MIT License
913 stars 156 forks source link

How to convert vargv to va_list in C #284

Closed Lenheart357 closed 5 months ago

Lenheart357 commented 5 months ago

This Is Squirrel Function

testfunc(1,2,3,4);

This Is C Function static SQInteger CallFunc(HSQUIRRELVM v) { // i want get my vargv

CallT<void *>(0x80FDCFC, va_list);
return 0;

}

zeromus commented 5 months ago

I doubt there is any safe way to do this. You will have to use dark magic to create a va_list dynamically in a manner compliant with your compiler and compiler options. It is better if you redesign your system this way

//void vafunc(fmt, ...) //delete this struct vathing { enum typeofthing; void ptrtothing; vathing nextthing; } void vafunc_real(fmt, vathing* things) { //do the work void vafunc(fmt, ...) { //create vathing list, call vafunc_real SQInteger CallFunc(HSQUIRRELVM v) { //create vathing list using squirrel apis to check stack, call vafunc_real

(consider making a function shared between vafunc and CallFunc to parse the fmt string)

Please say this is possible. If not.. maybe the dark magic is like this... https://bbs.archlinux.org/viewtopic.php?id=31087

Lenheart357 commented 5 months ago

i did it , thanks for your advice