#16 closed defect (released)
MacOS X compiler does not like getopt() declaration
Reported by: | Kees van Reeuwijk | Owned by: | Olly Betts |
---|---|---|---|
Priority: | high | Milestone: | |
Component: | Library API | Version: | other |
Severity: | normal | Keywords: | |
Cc: | Blocked By: | ||
Blocking: | Operating System: | Mac OS X |
Description
Compiling xapian-core-0.7.1 on MacOS X 10.2 with the current Apple g++ compiler causes an error in common/getopt.h. The declaration
extern int getopt();
at line 149 of that file clashes with a declaration in <stdlib.h>. This is understandable, since in C++ this declares a function without parameters, instead of a function with unknown parameters, as is intended.
The core problem is that somehow the Apple libraries are not recognized as GCC libraries, but I didn't want to mess with that. Instead I solved the problem by replacing the line shown above with:
# ifdef cplusplus extern int getopt(int, char * const *, const char *); # else extern int getopt(); # endif
Change History (4)
comment:1 by , 21 years ago
Status: | new → assigned |
---|
comment:2 by , 21 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Fixed getopt.h. The fix in the other project was actually to only include getopt.h from C sources, which doesn't really help us with Xapian.
comment:4 by , 21 years ago
Operating System: | → Mac OS X |
---|---|
Resolution: | verified → released |
I've encountered this same problem in another project on MacOS X. I'll check how we fixed it there (I think we might have upgraded to a new GNU getopt) and fix it for Xapian too.