Max Feldkamp
Max Feldkamp

Reputation: 527

Using __argc and __argv in 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);
}

Upvotes: 7

Views: 3830

Answers (1)

James McNellis
James McNellis

Reputation: 355049

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.

Upvotes: 7

Related Questions