Skip to main content
gamedev.net
🔒 Locked

::__argc and ::__argv in Dev-CPP

Started by MDI Feb 3, 2003 at 2:00 PM 3 replies 400+ views
Original Post
MDI
MDI
Lo. The following code, for some reason, refuses to compile in Dev-CPP, but compiles fine in MSVC. I am sure that it has compiled before, at college, but now at home Dev-CPP will not recognise :: __argc and :: __argv (with or without the :: operators).
unsigned int winBPP = CommandLine :: getInt ("-b", __argv, __argc);
 
Does anyone have any idea why this is so? Is __argc and __argv vendor specific (ie MSVC specific)? If that''s the case, what other ways are there of getting the command line parameters and the command line parameter count? TIA.
Sneftel
Sneftel
yes, __argc and __argv are compiler-specific. Any identifier beginning with two underscores is.

Most people, even those using MSVC++, don''t use those. They use the argc and argv arguments to main:


  
int main(int argc, char *argv[])
{
for(int i=1; i<argc;i++)
{
cout << "Argument " << i << " is " << argv[i] << ".\n";
}
return 0;
}



Don''t listen to me. I''ve had too much coffee.
Null and Void
Null and Void
quote:
Original post by MDI
Is __argc and __argv vendor specific (ie MSVC specific)?

Yes.

quote:
Original post by MDI
If that''s the case, what other ways are there of getting the command line parameters and the command line parameter count?

From the parameters passed to main is the normal place .

However, it appears that MinGW has a closer match: _argc and _argv (one underscore) are defined in stdlib.h. Although the two underscore prefixed versions may exist in there too, I haven''t checked that well.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.