Bug 111209 - /usr/include/net-snmp/utilities.h defines getopt() incorrectly
/usr/include/net-snmp/utilities.h defines getopt() incorrectly
Product: Fedora
Classification: Fedora
Component: net-snmp (Show other bugs)
All Linux
medium Severity medium
: ---
: ---
Assigned To: Phil Knirsch
Depends On:
  Show dependency treegraph
Reported: 2003-11-29 23:40 EST by Ori Pessach
Modified: 2015-03-04 20:13 EST (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2003-12-10 09:34:05 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Ori Pessach 2003-11-29 23:40:56 EST
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4.1)

Description of problem:
When compiling wap11gui (http://wap11gui.sourceforge.net), I run into
the following error:

g++ -DHAVE_CONFIG_H -I. -I. -I.. -I/usr/lib/qt-3.1/include
-DDATADIR=\"/usr/local/share/wap11gui\" -Wnon-virtual-dtor
-Wno-long-long -Wbad-function-cast -Wundef -Wall -pedantic -W
-Wpointer-arith -Wmissing-prototypes -Wwrite-strings -ansi
-D_XOPEN_SOURCE=500 -D_BSD_SOURCE -Wcast-align -Wconversion -O2
-fno-exceptions -fno-check-new -fexceptions -DNET_SNMP=1  -c -o
macauthimp.o `test -f macauthimp.cpp || echo './'`macauthimp.cpp
cc1plus: warning: "-Wbad-function-cast" is valid for C/ObjC but not
for C++
In file included from /usr/include/net-snmp/utilities.h:26,
~                 from /usr/include/net-snmp/net-snmp-includes.h:64,
~                 from wap11config.h:24,
~                 from macauthimp.h:21,
~                 from macauthimp.cpp:22:
/usr/include/net-snmp/library/getopt.h:8: error: declaration of `int
~   getopt(int, char* const*, const char*)' throws different exceptions
/usr/include/getopt.h:154: error: than previous declaration `int
~   char* const*, const char*) throw ()'
make[1]: *** [macauthimp.o] Error 1
make[1]: Leaving directory `/home/ori/projects/wap11gui/wap11gui'
make: *** [all-recursive] Error 1

The problem is that /usr/include/net-snmp/utilities.h defines getopt()
as an extern, instead of including <getopt.h>, as it probably should.

The proper getopt.h is included by unistd.h, which, in a QT app, is
included somewhere inside the bowels of QT. This means that every QT
app that tries to use net-snmp under Fedora won't compile. I can't
think of any way an application could work around this.

This appears to be a new problem - RH 9 and 8.0 didn't have this, and
I haven't seen this problem on any other platform I tried compiling on
(Mandrake, SuSe, FreeBSD and Mac OS X).

Version-Release number of selected component (if applicable):
net-snmp-devel 5.0.9

How reproducible:
Comment 1 Ori Pessach 2003-12-06 12:22:48 EST
Correction: /usr/include/net-snmp/utilites.h doesn't declare getopt()
as an extern. Instead, it includes a net-snmp private getopt.h header,
which in turn has the extern declaration.

On my system, patching utilites.h to include the proper <getopt.h>
instead of the private version solves my problem, and doesn't seem to
have any other effects, but I haven't done a lot of testing. Is there
a way to submit a patch for this? (pending more testing)
Comment 2 Ori Pessach 2003-12-08 17:43:28 EST
I reported this to the net-snmp team. This is the bug report, and the


Their fix was to apply the following patch:

diff -u -r5.5 utilities.h
--- include/net-snmp/utilities.h        17 Aug 2003 22:09:21
-0000      5.5
+++ include/net-snmp/utilities.h        8 Dec 2003 22:07:28
@@ -27,7 +27,11 @@

 #include <net-snmp/library/snmp_api.h>
 #include <net-snmp/library/snmp_client.h>
+#include <getopt.h>
 #include <net-snmp/library/getopt.h>

 #include <netinet/in.h>         /* for in_addr_t */

Would it be possible to apply this to the current Fedora net-snmp package?
Comment 3 Phil Knirsch 2003-12-10 09:34:05 EST
Yep, will be included in net-snmp-5.1-3 and later.

Read ya, Phil
Comment 4 Ori Pessach 2003-12-10 13:18:07 EST
Ok then - any chance of this appearing as an update to Fedora Core 1?
A project I maintain won't compile on FC1 as a result of this problem.
Comment 5 Phil Knirsch 2003-12-10 13:58:31 EST
Sure, shouldn't be a problem. I'll make a package for fc1 tomorrow.

Read ya, Phil
Comment 6 Ori Pessach 2003-12-10 14:16:55 EST

Note You need to log in before you can comment on or make changes to this bug.