开发者

Command arguments in compiler configurations

开发者 https://www.devze.com 2022-12-21 04:23 出处:网络
[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 debuggi

[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开发者_如何学C 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.


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:

  • What's is WinMain
  • How to get normal argv-style command line parameters


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消