Re: Compilation error with net-snmp header files
Pavlin Radoslavov <[email protected]>
| Newsgroups | gmane.network.net-snmp.user |
|---|---|
| Message-ID | <[email protected]> |
> OS: FreeBSD-4.10-RELEASE
> (with /usr/local/include/getopt.h header file added by some packages)
> Net-SNMP: 5.2.1.2
> Compiler: gcc-3.4.2
>
> If I try to compile the following sample program:
>
> #include <net-snmp/net-snmp-config.h>
> #include <net-snmp/net-snmp-includes.h>
> #include <net-snmp/agent/net-snmp-agent-includes.h>
>
> #include <unistd.h>
>
> int
> main()
> {
> exit(0);
> }
>
> with the following arguments:
> g++34 `~/net-snmp/bin/net-snmp-config --cflags` bar.cc
>
> it fails with the following errors:
>
> pavlin@possum[483] g++34 `~/net-snmp/bin/net-snmp-config --cflags` bar.cc
> In file included from bar.cc:5:
> /usr/include/unistd.h:112: error: declaration of C function `int
> getopt(int, char* const*, const char*)' conflicts with
> /usr/local/include/getopt.h:115: error: previous declaration `int
> getopt()' here
> /home/possum/u0/pavlin/net-snmp/include/net-snmp/agent/agent_handler.h:238:
> warning: inline function `void*
> netsnmp_request_get_list_data(netsnmp_request_info*, const char*)'
> used but never defined
> Exit 1
>
> The problem is that on FreeBSD getopt() may be declared in both
> <unistd.h> and /usr/local/include/getopt.h, and we shouldn't include
> both files. The latter is included by <net-snmp/utilities.h> if
> HAVE_GETOPT_H is defined.
>
> Also note the second (probably independent) error about
> netsnmp_request_get_list_data() being used but never defined.
>
> Both errors are with gcc-3.4 (and probably the gcc-4.x branch), but
> are not with the gcc-2.95.4 compiler.
After some investigation I found that the second error can be
eliminated if the inlined functions are disabled by adding
-DNETSNMP_NO_INLINE to the compiler's flags.
Any suggestions how to fix the first error?
The ugly hack I use for testing purpose is to add
"#undef HAVE_GETOPT_H" after "#include <net-snmp/net-snmp-config.h>"
but this is not an acceptable solution.
Pavlin
-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Net-snmp-users mailing list
[email protected]
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users