OpenTTD

Tasklist

FS#4751 - [OSX 10.7] strndup warning when compiling on lion

Attached to Project: OpenTTD
Opened by Lee (leecbaker) - Sunday, 28 August 2011, 03:45 GMT
Last edited by Ingo von Borstel (planetmaker) - Sunday, 04 September 2011, 11:29 GMT
Type Patch
Category Core
Status Closed
Assigned To No-one
Operating System Mac OS X
Severity Low
Priority Normal
Reported Version trunk
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Before Lion / 10.7, Mac OS X didn't include the strndup function (previously a GNU extension to the standard library, now part of POSIX 2008). In 10.7, this function is present. When compiling OpenTTD, multiply-defined function warnings occur in many files while compiling. For example:

[SRC] Compiling viewport.cpp
In file included from /Users/lee/openttd/trunk/src/blitter/factory.hpp:17,
from /Users/lee/openttd/trunk/src/viewport.cpp:39:
/Users/lee/openttd/trunk/src/blitter/../string_func.h:202: warning: redundant redeclaration of ‘char* strndup(const char*, size_t)’ in same scope
/usr/include/string.h:142: warning: previous declaration of ‘char* strndup(const char*, size_t)’

In Apple's /usr/include/string.h, they use the following guard to prevent strndup from being included in earlier versions:

#if __DARWIN_C_LEVEL >= 200809L

I've included a 1 line modification to string_func.h to prevent OpenTTD's implementation from being included. This eliminates the warning when compiling. I have not been able to test the compiled OpenTTD running on Lion due to #4695.
This task depends upon

Closed by  Ingo von Borstel (planetmaker)
Sunday, 04 September 2011, 11:29 GMT
Reason for closing:  Fixed
Additional comments about closing:  In r22889. Thanks for the patch.

Loading...