Ticket #16 (closed defect: released)

Opened 6 years ago

Last modified 5 years ago

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

Change History

Changed 6 years ago by olly

  • status changed from new to assigned

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.

Changed 6 years ago by olly

  • status changed from assigned to closed
  • resolution set to fixed

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.

Changed 5 years ago by olly

  • resolution changed from fixed to verified

Verified fixed on cf.sf.net MacOS X box

Changed 5 years ago by olly

  • resolution changed from verified to released

Changed 5 years ago by trac

  • platform set to Mac OS X
Note: See TracTickets for help on using tickets.