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.

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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.