Opened 21 years ago

Closed 21 years ago

Last modified 21 years ago

#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 Olly Betts, 21 years ago

Status: newassigned

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.

comment:2 by Olly Betts, 21 years ago

Resolution: fixed
Status: assignedclosed

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:3 by Olly Betts, 21 years ago

Resolution: fixedverified

Verified fixed on cf.sf.net MacOS X box

comment:4 by Olly Betts, 21 years ago

Operating System: Mac OS X
Resolution: verifiedreleased
Note: See TracTickets for help on using tickets.