Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CLion - command line program arguments

Tags:

cmake

clion

Can anyone tell me what wrong with JetBrains CLion, when I assign to Run/Debug Configurations - Program arguments something like "aaa bbb" and then print it:

printf("%s\n", argv[1]);

I just got "aaa", when it must be "aaa bbb" because they are in double quotes.

picture - this is what i get

Edit: tested in other IDEs (Dev C++, Codelite) and it works. Only Clion does not :( Just simple thing and can not figure it out...

like image 506
Zuy BK Avatar asked Nov 08 '15 21:11

Zuy BK


People also ask

How do you pass command line arguments in CLion?

From the main menu, select Run | Edit Configurations or choose Edit Configurations from the run/debug configurations selector on the toolbar. In the Run/Debug Configurations dialog that opens, select a configuration where you want to pass the arguments. Type the arguments in the Program arguments field.

How do you use CLion command line?

To run CLion from the shell, use the open command with the following options: -a : specify the application. --args : specify additional arguments when passing more than just the file or directory to open. -n : open a new instance of the application even if one is already running.

How do I debug executable in CLion?

In CLion, call Run | Attach to Process from the main menu or press Ctrl+Alt+F5 . After the debugger is attached successfully, you will be able to debug as usual. See the Debugging section for details. on the toolbar or in the Debug tool window to detach from the process.

How do you run in release mode CLion?

For newer versions: Go to File --> Settings --> Build, Execution, Deployment --> CMake. Now click the "+" symbol, this should automatically add a Release profile (and, if you press "+" again, a Release with Debug Information profile).


2 Answers

This appears to be a bug in CLion. For me, it only happens when I start the application without debugging it (Run > Run 'Test'). When I start in debug mode (Run > Debug 'Test'), it works fine and displays the whole string.

I've created an issue with JetBrains. I'll update this answer as soon as I hear back from them.

like image 177
Daniel Wolf Avatar answered Oct 08 '22 09:10

Daniel Wolf


Don't use Quotation marks("") and also make sure to delete any preceding spaces in Program argument text field in Run/Debug Configurations Windows, check the following screenshot.

image courtesy: uta
screenshot

like image 21
M.Siri Avatar answered Oct 08 '22 09:10

M.Siri