So I am writing a wrapper for main and still provide a main like functionality, so user can define int main() or int main(argc, argv) and both works fine. I am able to do that for some compilers with inline assembly with pushing argc & argv onto stack before calling the user's main. However for x64 VC++, there is no inline assembly, so any suggestions on how I can achieve this?

Thanks!

有帮助吗?

解决方案

I see two obvious choices: either write your code in assembly language, contained in an assembly language file, or else write your code in C++ without any inline assembly:

void my_entry_point() { 
     int argc = foo();
     int argv = bar();
     int ret = main(argc, argv);
     exit_to_os(ret);
}
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top