[109111] trunk/dports/science/gstlal-inspiral/Portfile

Adam Mercer ram at macports.org
Thu Aug 8 12:05:48 PDT 2013


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?

Cheers

Adam


More information about the macports-dev mailing list