[109111] trunk/dports/science/gstlal-inspiral/Portfile
Joshua Root
jmr at macports.org
Thu Aug 8 12:14:13 PDT 2013
On 2013-8-9 05:05 , Adam Mercer wrote:
> On Thu, Aug 8, 2013 at 11:19 AM, Adam Mercer <ram at macports.org> wrote:
>
> Jeremy
>
>> So adding something like the following to the file that is failing is
>> the appropriate fix?
>>
>> /*
>> * Mac OS X 10.6 and lower do not contain strndup, define this
>> * statically if needed
>> */
>>
>> #if __MAC_OS_X_VERSION_MIN_REQUIRED < 1070
>> static char *strndup(const char *str, size_t n)
>> {
>> size_t len;
>> char *copy;
>>
>> for (len = 0; len < n && str[len]; len++)
>> continue;
>>
>> if ((copy = malloc(len + 1)) == NULL)
>> return (NULL);
>> memcpy(copy, str, len);
>> copy[len] = '\0';
>> return (copy);
>> }
>> #endif
>
> So I tried this on a Snow Leopard machine (running Xcode-3.2.6) and
> the compiler complained that there was an invalid conversion from
> 'void*' to 'char*', replacing the call to malloc() in the above with:
>
> if ((copy = (char*)malloc(len + 1)) == NULL)
>
> allowed compilation to proceed. You seem more familiar with this so is
> this a valid approach or should I be doing something else?
Sounds like it's being compiled as C++, where the rules are different to
C. The explicit cast should be correct.
- Josh
More information about the macports-dev
mailing list