Index: docs/CommandLine.rst =================================================================== --- docs/CommandLine.rst +++ docs/CommandLine.rst @@ -355,7 +355,7 @@ clEnumVal(g , "No optimizations, enable debugging"), clEnumVal(O1, "Enable trivial optimizations"), clEnumVal(O2, "Enable default optimizations"), - clEnumVal(O3, "Enable expensive optimizations"))); + clEnumVal(O3, "Enable expensive optimizations"), clEnumValEnd)); ... if (OptimizationLevel >= O2) doPartialRedundancyElimination(...); @@ -366,8 +366,9 @@ are listed in the declaration. The CommandLine library enforces that the user can only specify one of the options, and it ensure that only valid enum values can be specified. The "``clEnumVal``" macros ensure that the command -line arguments matched the enum values. With this option added, our help output -now is: +line arguments matched the enum values, and always remember to add "``clEnumValEnd``" +at the end since argument list for "``cl::values``" should be end with null. +With this option added, our help output now is: :: @@ -399,7 +400,7 @@ clEnumValN(Debug, "g", "No optimizations, enable debugging"), clEnumVal(O1 , "Enable trivial optimizations"), clEnumVal(O2 , "Enable default optimizations"), - clEnumVal(O3 , "Enable expensive optimizations"))); + clEnumVal(O3 , "Enable expensive optimizations"), clEnumValEnd)); ... if (OptimizationLevel == Debug) outputDebugInfo(...); @@ -433,7 +434,8 @@ cl::values( clEnumValN(nodebuginfo, "none", "disable debug information"), clEnumVal(quick, "enable quick debug information"), - clEnumVal(detailed, "enable detailed debug information"))); + clEnumVal(detailed, "enable detailed debug information"), + clEnumValEnd)); This definition defines an enumerated command line variable of type "``enum DebugLev``", which works exactly the same way as before. The difference here is @@ -494,7 +496,7 @@ clEnumVal(dce , "Dead Code Elimination"), clEnumVal(constprop , "Constant Propagation"), clEnumValN(inlining, "inline", "Procedure Integration"), - clEnumVal(strip , "Strip Symbols"))); + clEnumVal(strip , "Strip Symbols"), clEnumValEnd)); This defines a variable that is conceptually of the type "``std::vector``". Thus, you can access it with standard vector @@ -553,7 +555,7 @@ clEnumVal(dce , "Dead Code Elimination"), clEnumVal(constprop , "Constant Propagation"), clEnumValN(inlining, "inline", "Procedure Integration"), - clEnumVal(strip , "Strip Symbols"))); + clEnumVal(strip , "Strip Symbols"), clEnumValEnd)); To test to see if ``constprop`` was specified, we can use the ``cl:bits::isSet`` function: