Hello,
I was working on an ns-3.45 simulation (using CMake, g++ 13, Ubuntu 22.04). Having tried to implement a function to configure different privacy schemes for vehicles using
an enum SchemeType.
When building, I got these errors:
[ 99%] Building CXX object scratch/CMakeFiles/scratch_ns3_privacy_comparison.dir/ns3_privacy_comparison.cc.o
/home/idrab/ns-3.45/scratch/ns3_privacy_comparison.cc: In function ‘void InstallVehicleApp(ns3::NodeContainer, SchemeType)’:
/home/idrab/ns-3.45/scratch/ns3_privacy_comparison.cc:46:11: error: ‘else’ without a previous ‘if’
46 | } else if (scheme == BASELINE_CRYPTO_ONLY) {
| ^~~~
...
/home/idrab/ns-3.45/scratch/ns3_privacy_comparison.cc:47:51: error: ‘i’ was not declared in this scope
47 | NS_LOG_INFO("[BASELINE1] Vehicle " << i << ": Sending ECC signed pseudonym at " << start << "s");
...
/home/idrab/ns-3.45/scratch/ns3_privacy_comparison.cc:48:41: error: ‘start’ was not declared in this scope
48 | Simulator::Schedule(Seconds(start), [](){
...
/home/idrab/ns-3.45/scratch/ns3_privacy_comparison.cc:59:1: error: expected declaration before ‘}’ token
59 | }
/home/idrab/ns-3.45/src/core/model/command-line.h:811:9: error: no match for ‘operator>>’ (operand types are ‘std::istringstream’ and ‘SchemeType’)
My questions:
How should I properly structure the else if so it compiles inside a loop over vehicles?
Why are i and start undeclared inside my else if blocks?
How can I fix the operator>> error when using CommandLine with my enum SchemeType?