1

[edit] I meant to say "command arguments in compiler configs" . for the title.

I am trying to get into game mods. And I am trying to implement the source sdk. one of the steps is to go into debugging in my compiler configurations and add some data to the command arguments

-dev -sw -game "C:\Program Files (x86)\Steam\steamapps\SourceMods\firstmod"

Now I know what command arguments are. They are passed through the parameters of WinMain and judging by the name in the compiler configurations. I assume that has something to do with it. or maybe not. I am just not sure if the above would be considered 1 argument or multiple arguments. and what is it trying to achieve by passing a directory through. They weren't too detailed with the information.

1
  • Are you asking what the parameters do or how you should add them.
    – rerun
    Feb 26, 2010 at 19:44

2 Answers 2

1

In a normal (read console) C/C++ application you would have program entry point with the following declaration:

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

Here argc is the number of command line "strings", including the command itself, while argv is the array of these strings. So in your example it'd be argc of 5 (adding the program name), and argv[0] is the name of the program, argv[1] is "-dev", etc.

Now under Windows a GUI application is different - the entry point is declared as:

int WINAPI WinMain(      
    HINSTANCE hInstance,
    HINSTANCE hPrevInstance,
    LPSTR lpCmdLine,
    int nCmdShow
);

So the whole command line (this time excluding the app name) is pointed to by lpCmdLine, so it'd be one string as you put it above. There are helper functions to split that string though. Take a look at these two entries on MSDN:

1

Your example has four arguments:

  1. -dev
  2. -sw
  3. -game
  4. C:\Program Files (x86)\Steam\steamapps\SourceMods\firstmod

Because the last argument is surrounded by quotes, the Windows command line parser will consider it a single argument.

As for what it's trying to achieve by passing a directory, it's impossible to know for sure without seeing what the code does. But one guess is that the build will generate multiple interrelated files that are all supposed to live in a single directory; so you specify the directory and all the files will be created there.

2
  • If I remember well the first arg is the binary path as on Linux. Which means 5 arguments not 4. Feb 26, 2010 at 20:37
  • Do you mean "quotes" and not "parentheses"? Feb 26, 2010 at 20:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.