Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: eqychan on March 13, 2022, 11:23:53 am

Title: Set program's arguments don't work with vs2015 build tools & CDB
Post by: eqychan on March 13, 2022, 11:23:53 am
I made a program (simple console app ywfxvs.exe) in C++. I set the arguments in Project -> set program's arguments and fill the program arguments edit box with "1018" (without quotes), but it don't work. when I debug the program, argc is still 1, and argv[1] is "".
Am I doing a mistake somewhere ? Thanks.

My environment: Windows 7 32bit; Codeblocks 20.03; Visual studio build tools 2015; debugger: CDB (windows kits 8.1)
Title: Re: Set program's arguments don't work with vs2015 build tools & CDB
Post by: BlueHazzard on March 14, 2022, 11:55:13 am
Make sure you have selected the right "target" in the programs argurments dialog and when you run your application (the drop down menu near the run button)
Title: Re: Set program's arguments don't work with vs2015 build tools & CDB
Post by: eqychan on March 15, 2022, 06:44:00 am
Thanks for your reply, I did select the right and same "target" when debug the application.
And now I found that when I use GDB as the debugger or run the program without debugging, it works fine. but when i change the debugger to CDB and press F8 to debug my program, again i cannot see the arguments in my program.  Any problems with my CDB parameter settings?(My debugger setting showing in the attatchment)
Title: Re: Set program's arguments don't work with vs2015 build tools & CDB
Post by: BlueHazzard on March 15, 2022, 09:15:10 am
A sry, my fault, i did not realize that you are talking about debugging.

Please enable full debug log in Settings->Debugger->Common->Full Debug log

Then start your debugger, and post the output of the "Debugger" tab in the log view at the bottom in code tags here (use the # in the new post editor of the forum)

thank you!
Title: Re: Set program's arguments don't work with vs2015 build tools & CDB
Post by: Miguel Gimenez on March 15, 2022, 09:34:28 am
From cdb_driver.cpp:81 and cdb_driver.cpp:97
Code
// FIXME (obfuscated#): Implement user arguments
so looks like CDB ignores user arguments ATM.
Title: Re: Set program's arguments don't work with vs2015 build tools & CDB
Post by: Miguel Gimenez on March 15, 2022, 10:07:54 am
I have just commited a patch to fix this, I can not test it because I do not have CDB, but the change is straightforward:
Code
+    if (!userArguments.empty())
+        cmd << ' ' << userArguments;
Title: Re: Set program's arguments don't work with vs2015 build tools & CDB
Post by: eqychan on March 16, 2022, 11:28:31 am
Thanks for your replay, I applied your patch and rebuilt Codeblocks form source, now it works pretty fine. thanks ;D
Title: Re: Set program's arguments don't work with vs2015 build tools & CDB
Post by: Miguel Gimenez on March 16, 2022, 12:50:56 pm
Thank you for testing and reporting.