Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using __argc and __argv in MinGW

Tags:

c++

mingw

I was wondering, is there any nice way to use the builtins __argc and __argv (like in Visual C++) in MinGW (I'm including windows.h already), or will I have to do something more involved to access these parameters. I'd so very much like to just have this code work in MinGW (but we don't always get what we wish for):

#include <windows.h>

extern int main(int argc, char* argv[]);

int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, INT)
{
    return main(__argc, __argv);
}
like image 260
Max Feldkamp Avatar asked Jul 30 '13 23:07

Max Feldkamp


1 Answers

These aren't "builtins," they are global variables provided by the C Runtime. They are declared in <stdlib.h> in both the Visual C++ library headers and in Stephan's MinGW distro. If they aren't declared in your copy of <stdlib.h>, just declare them yourself.

like image 124
James McNellis Avatar answered Oct 17 '22 00:10

James McNellis