[Click] ANNOUNCE/RFC: Type-safe argument parsing

Roberto Riggio roberto.riggio at create-net.org
Tue May 10 12:44:03 EDT 2011


args.hh also needs this include:

#include <stdarg.h>

otherwise i get a compilation error (va_list not found)

However I do not understand why on by ubuntu pc everything works fine
while the error is actually generated when trying to compile for openwrt.

R.

Il 10/05/2011 16:40, Eddie Kohler ha scritto:
> Whoops!  Sorry about that; fixed.
>
> E
>
>
> On 5/10/11 2:52 AM, Roberto Riggio wrote:
>> Something is missing:
>>
>> CXX ../elements/standard/addressinfo.cc
>> ../elements/standard/addressinfo.cc: In member function ‘virtual int
>> AddressInfo::configure(Vector<String>&, ErrorHandler*)’:
>> ../elements/standard/addressinfo.cc:97: error: ‘EtherAddressArg’ was not
>> declared in this scope
>>
>>
>> Il 10/05/2011 02:35, Eddie Kohler ha scritto:
>>> All,
>>>
>>> The argument parsing branch is merged!  Thanks for your comments.
>>>
>>> Eddie
>>>
>>>
>>> On 04/28/2011 01:26 PM, Eddie Kohler wrote:
>>>> Hi all,
>>>>
>>>> A longstanding Click annoyance is argument parsing, which has been 
>>>> rewritten
>>>> more than once.
>>>>
>>>> There are still problems with the current cp_va_kparse versions.
>>>>
>>>> - Type safety: Did you know that this is a serious bug, that the 
>>>> compiler
>>>> cannot catch?
>>>>
>>>> #include<click/confparse.hh>
>>>> bool b;
>>>> ...
>>>> if (cp_va_kparse(conf, this, errh,
>>>>                  "I_FORGOT_WHAT_B_WAS", cpkP+cpkM, cpInteger,&b,
>>>>                  cpEnd)<    0)
>>>>         return -1;
>>>>
>>>> - Multithread safety: Did you know that if cp_va_kparse is called 
>>>> in parallel
>>>> in two threads, the two calls will unsafely collide on a static 
>>>> array of
>>>> "cp_value" objects?
>>>>
>>>> - Multithread safety: Did you know that cp_integer() and friends 
>>>> set a global
>>>> variable, cp_errno -- and that cp_errno settings can collide across 
>>>> threads?
>>>>
>>>> -*-
>>>>
>>>> The github "argparse" branch, which will soon be shifted to master, 
>>>> fixes
>>>> these problems with a new Args class.  Args is much nicer to type 
>>>> and read
>>>> than cp_va.
>>>>
>>>> #include<click/args.hh>
>>>> bool b;
>>>> ...
>>>> if (Args(conf, this, errh)
>>>>         .read_mp("B", b)
>>>>         .complete()<    0)
>>>>         return -1;
>>>>
>>>> There are other advantages: it's easier and cleaner to write and 
>>>> refer to new
>>>> parser types, for example.
>>>>
>>>> -*-
>>>>
>>>> I am interested in feedback and comments.  Please look and report any
>>>> problems.  Thanks to Cliff for discussion.
>>>>
>>>> Eddie
>>>> _______________________________________________
>>>> click mailing list
>>>> click at amsterdam.lcs.mit.edu
>>>> https://amsterdam.lcs.mit.edu/mailman/listinfo/click
>>> _______________________________________________
>>> click mailing list
>>> click at amsterdam.lcs.mit.edu
>>> https://amsterdam.lcs.mit.edu/mailman/listinfo/click
>>
>>


-- 
--------------------------------------------------------
Roberto Riggio, Ph.D.
CREATE-NET
Network&  Security Solutions for Pervasive Computing Systems (iNSPIRE)
Senior Researcher
Via alla Cascata 56/D - 38123 Povo Trento (Italy)
e-mail: roberto.riggio at create-net.org
Tel: (+39) 0461 408400 - interno/extension 708
Fax: (+39) 0461 421157
www.create-net.org/~rriggio
--------------------------------------------------------

The information transmitted is intended only for the person or entity to
which it is addressed and may contain confidential and/or privileged
material. Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by persons or
entities other than the intended recipient is prohibited according to
the Italian Law 196/2003 of the Legislature. If you received this in
error, please contact the sender and delete the material from any
computer.

Le informazioni contenute in questo messaggio di posta elettronica e nei
file allegati sono da considerarsi strettamente riservate. Il loro
utilizzo e' consentito esclusivamente al destinatario del messaggio, per
le finalita' indicate nel messaggio stesso. Qualora riceveste questo
messaggio senza esserne il destinatario, Vi preghiamo cortesemente di
darcene notizia via e-mail e di procedere alla cancellazione del
messaggio stesso dal Vostro sistema. Trattenere il messaggio stesso,
divulgarlo anche in parte, distribuirlo ad altri soggetti, copiarlo,
od utilizzarlo per finalita' diverse, costituisce comportamento
contrario ai principi dettati dal D. Lgs. 196/2003.




More information about the click mailing list