[llvm-dev] llvm::cl::opt and enums

Martin J. O'Riordan via llvm-dev llvm-dev at lists.llvm.org
Thu Sep 1 02:16:28 PDT 2016


I have to follow up to this, and say thanks very much to you Renato.

 

Your recommended solution not only works perfectly, it is also very elegant and I can use meaningful words for the options instead of having to remember the enumerate values.  It is also far safer, because it rejects invalid values.

 

Thanks again,

 

            MartinO

 

-----Original Message-----
From: Renato Golin [mailto:renato.golin at linaro.org] 
Sent: 31 August 2016 19:13
To: Martin J. O'Riordan <Martin.ORiordan at movidius.com>
Cc: LLVM Developers <llvm-dev at lists.llvm.org>
Subject: Re: [llvm-dev] llvm::cl::opt and enums

 

On 31 August 2016 at 19:06, Martin J. O'Riordan via llvm-dev < <mailto:llvm-dev at lists.llvm.org> llvm-dev at lists.llvm.org> wrote:

> but that doesn’t work, and I get something like “invalid option ‘3’”.  

> If I change the type to ‘int’ it works fine.  Is it valid to use an 

> ‘enum’ in this way?  And if so, what is the correct way of specifying 

> a value to the option if I do use an ‘enum’ for the type?

 

Try something similar to this:

 

 <https://reviews.llvm.org/D24070> https://reviews.llvm.org/D24070

 

cheers,

--renato

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160901/0c206ab6/attachment.html>


More information about the llvm-dev mailing list