Ticket #16 (closed defect: released)
MacOS X compiler does not like getopt() declaration
| Reported by: | C.vanReeuwijk | Owned by: | olly |
|---|---|---|---|
| Priority: | high | Milestone: | |
| Component: | Library API | Version: | other |
| Severity: | normal | Keywords: | |
| Cc: | Blocked By: | ||
| Operating System: | Mac OS X | Blocking: |
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
