On Wed, Jul 30, 2008 at 04:39:44PM +0300, Christophe Melki wrote:

> Then I tried to program a C++ API to get it to poll several server
> using snmp agents and gather information in a database. On the
> net-snmp
> tutorial website, there is a example code about asynchronous polling
> which is perfect for my demand, but is coded in C.
> I tried compiling it with C++, but I get one error that makes my
> application fail, and this error does not show if I compile in C.

It's a namespace thing.

> struct oid {
> const char *Name;
> oid Oid[MAX_OID_LEN];
> int OidLen;
> }

[excerpted error message]

> g++ -I/usr/local/include -I/usr/include/mysql -g -c Testincpp.cpp
> -o Testincpp.oTestincpp.cpp:41: error: conflicting declaration 'struct
> oid'/usr/include/net-snmp/types.h:47: error: 'oid' has a previous
> declaration as `typedef u_long oid'

The struct named 'oid' is colliding with the typedef for 'oid'. Change
the struct name and you should be good to go.
Roy M. Silvernail is roy@rant-central.com, and you're not
"A desperate disease requires a dangerous remedy."
- Guy Fawkes

This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
Net-snmp-coders mailing list