Bug 930 - examples/topology-read/topology-example-sim.cc uses variable length array
examples/topology-read/topology-example-sim.cc uses variable length array
Status: RESOLVED FIXED
Product: ns-3
Classification: Unclassified
Component: examples
ns-3-dev
All All
: P5 normal
Assigned To: Josh Pelkey
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2010-05-31 01:54 UTC by Quincy Tse
Modified: 2010-08-10 23:23 UTC (History)
2 users (show)

See Also:


Attachments
Proposed patch. (1.28 KB, patch)
2010-05-31 02:13 UTC, Quincy Tse
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Quincy Tse 2010-05-31 01:54:51 UTC
topology-example-sim.cc uses variable length array, which cannot be compiled using some compilers (especially strict standards-compilent compilers like clang). Variable length array is part of C99 but does not comply with C++ standards (not in C++98, rejected for C++0x).
Comment 1 Quincy Tse 2010-05-31 02:13:08 UTC
Created attachment 902 [details]
Proposed patch.
Comment 2 Josh Pelkey 2010-08-05 14:16:18 UTC
Are we making a decision here to say no to variable-length arrays in ns-3?
Comment 3 Tom Henderson 2010-08-06 14:26:51 UTC
(In reply to comment #2)
> Are we making a decision here to say no to variable-length arrays in ns-3?

I slightly lean towards this because it is not standard and there are other viable solutions in C++ (such as new[] or std::vector).

If no other comments from developers I suggest to apply the patch and add this statement to the coding style:

"variable-length arrays are not standards-compliant C++; use instead std::vector, std::string, or operator new[] when your code might call for a variable-length array."
Comment 4 Josh Pelkey 2010-08-10 23:23:50 UTC
changeset: caa2dd9bbbce

I also updated the webpage, changeset: f27e0846b0c4