[Nagios-devel] Nagios headers fails to compile in C++

Matthieu Kermagoret mkermagoret at merethis.com
Thu Dec 16 12:19:11 UTC 2010

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.

> 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++.

Wouldn't the _t suffix be appropriate (ie. host_t, service_t) ? It is
a widely used suffix for type names.

Best regards,

Matthieu KERMAGORET | Développeur

mkermagoret at merethis.com

MERETHIS est éditeur du logiciel Centreon.

More information about the Nagios-devel mailing list