Bug 2916 - Command Line Parser treats uint8_t as char
Command Line Parser treats uint8_t as char
Status: RESOLVED MOVED
Product: ns-3
Classification: Unclassified
Component: core
ns-3.28
All All
: P3 normal
Assigned To: Peter Barnes
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2018-05-02 07:55 EDT by Jörg Christian Kirchhof
Modified: 2020-05-04 09:53 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jörg Christian Kirchhof 2018-05-02 07:55:01 EDT
Overview:
The CommandLine parser treats uint8_t as char. Therefore uint8_t variables get treated unintuitively.

Steps to Reproduce: 
1) Create a script that uses a uint8_t command line argument:
int
main (int argc, char *argv[]) 
{
  uint8_t seed = 0;
  CommandLine cmd;
  cmd.AddValue ("value", "Some Explanation", seed);
  cmd.Parse (argc, argv);
}
2) Run the script with the argument "--value=1"

Actual Results: 
cmd.Parse (argc, argv) sets seed to 49, because 49 is the ASCII value of character '1'.

Expected Results: 
cmd.Parse (argc, argv) should set seed to 1.

Build Date & Hardware: 
ns-3.28 on Mac OS X High Sierra.

Additional Information: 
none.
Comment 1 sebastien.deronne 2020-04-07 05:33:36 EDT
It would worth to port this one to Gitlab, I've faced this problem again.
Comment 2 Peter Barnes 2020-04-08 20:39:11 EDT
Already there :)  See
https://gitlab.com/nsnam/ns-3-dev/-/merge_requests/235