Stilllegung des Forums
Das Forum wurde am 05.06.2023 nach über 20 Jahren stillgelegt (weitere Informationen und ein kleiner Rückblick).
Registrierungen, Anmeldungen und Postings sind nicht mehr möglich. Öffentliche Inhalte sind weiterhin zugänglich.
Das Team von spieleprogrammierer.de bedankt sich bei der Community für die vielen schönen Jahre.
Wenn du eine deutschsprachige Spieleentwickler-Community suchst, schau doch mal im Discord und auf ZFX vorbei!
Werbeanzeige
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
#include <iostream> using namespace std; template<int I> struct sizeHolder{ unsigned char p[I]; }; #define array_call(_func, _param) ( reinterpret_cast<void (_stdcall *)(sizeHolder<sizeof(_param)>)>(_func) ) \ ( *reinterpret_cast<sizeHolder<sizeof(_param)>*>(_param)) void Test(int a, int b, int c) { cout << "a: " << a << "\nb: " << b << "\nc: " << c; } int main(int argc, char* argv[]) { int p[] = { 5, 4, 99 }; cout << "Size: " << sizeof(p) << "\n"; array_call(&Test, p); cin.get(); return 0; } |
Quellcode |
|
1 2 3 |
Run-Time Check Failure #0 - The value of ESP was not properly saved across a function call. This is usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention. |
Administrator
Administrator
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
// Als erstes die Funktion void Say( const std::string& _msg, int times ) { for(int i = 0; i < times; ++i) sdt::cout << _mgs << std::endl; } // Dann den Aufrufer erzeugen FuncCaller caller; // Funktion registrieren caller.RegisterFunction("void Say(string, int)", &Say); // Und Datei aufrufen caller.ParseFile("Test.txt"); |
C-/C++-Quelltext |
|
1 2 3 4 |
// Test.txt Say("Hallo", 2) Say("Bye", 10) |
Administrator
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 |
// echte Funktion void myFunction(int a, float b, std::string c) { // tu was // ... } // Proxy-Funktion void myFunction_proxy(const Params& p) { // Parameter entpacken und weiterleiten myFunction(p.pop<int>(), p.pop<float>(), p.pop<std::string>()); } |
Administrator
Werbeanzeige