Nagios headers fails to compile in C++
Andreas Ericsson
ae at op5.se
Thu Dec 16 13:54:01 CET 2010
On 12/16/2010 01:19 PM, Matthieu Kermagoret wrote:
> On Thu, Dec 16, 2010 at 11:25 AM, Andreas Ericsson<ae at op5.se> wrote:
>> Oh. Can't C++ handle types as variable names? That's pretty weak tbh.
>
> Nop it cannot.
>
Why oh why. It's not as if the compiler can't discern the difference
between variable names and variable types. grrmbl
>> I'll make a note of it. In the future, the object types will be either
>> "struct<type>" or"<type>_object". We save no typing for either case,
>> and abbreviating "_object" to "_obj" seems a bit silly to me. We'll
>> probably go with "struct host". That will also make it possible to
>> name instances of the structs to the type they're referring to, such
>> that
>>
>> struct host *host;
>>
>> works well. Does this also work nicely with C++, or do we have to play
>> prefix/suffix games?
>>
>
> It does not work, because the struct keyword becomes optional when
> declaring a variable such as
>
> struct host { /* struct content */ };
> host h;
>
> is perfectly valid C++.
>
Bah. How does it handle "struct stat" vs "stat()" then? It seems pretty
inconsistent if it handles one thing but not the other.
> Wouldn't the _t suffix be appropriate (ie. host_t, service_t) ? It is
> a widely used suffix for type names.
>
It is widely used because it is reserved by POSIX for POSIX types.
size_t, socklen_t, pthread_mutex_t et al are all POSIX constructs, so
that path is barred to us.
Perhaps "nagios_host", "nag_host" or "n_host", although "n" is quite
commonly used as abbreviation for "number of".
Either way, rearranging the object names for this project alone
simply isn't worth it. Is there a particular reason you're dead set
on writing the broker module in c++ rather than in plain c? If so,
I'd recommend you importing the header files into your project and
editing the names as you see fit.
Oh, and could you submit a small patch that, with "make cppneb",
attempts to compile a microscopic C++ program using the core header
files? That would make it a lot easier for me to handle testing of
C++ functionality in the future. I'd write it myself, but I'm not
familiar with C++ rules (if that wasn't obvious), so I'd probably
botch the job completely.
--
Andreas Ericsson andreas.ericsson at op5.se
OP5 AB www.op5.se
Tel: +46 8-230225 Fax: +46 8-230231
Considering the successes of the wars on alcohol, poverty, drugs and
terror, I think we should give some serious thought to declaring war
on peace.
------------------------------------------------------------------------------
Lotusphere 2011
Register now for Lotusphere 2011 and learn how
to connect the dots, take your collaborative environment
to the next level, and enter the era of Social Business.
http://p.sf.net/sfu/lotusphere-d2d
More information about the Developers
mailing list