← Back to team overview

dulwich-users team mailing list archive

Re: OS X Lion: strnlen

 

Hi Daniele,

On Wed, 2011-06-08 at 14:39 +0200, Daniele Sluijters wrote:
> Yup it's the irritating Mac-guy again.
> 
> 
> Ran into a new problem with Lion Developer Preview 4 when trying to
> build dulwich with Python 2.7,1 and Xcode 4.1 Developer Preview 6.
> 
> 
> It seems that Apple's string.h now has a strnlen definition but
> dulwich isn't aware of that yet.

> The following code causes the build to break:
> #if defined(__MINGW32_VERSION) || defined(__APPLE__)
> size_t strnlen(char *text, size_t maxlen)
> {
>     const char *last = memchr(text, '\0', maxlen);
>     return last ? (size_t) (last - text) : maxlen;
> }
> #endif
Thanks for letting us know. 

CC'ing the bug tracker:

  affects dulwich
  status triaged
  importance medium
  tags +macosx

> Resulting in:
> dulwich/_objects.c:30: error: conflicting types for ‘strnlen’
> /usr/include/string.h:143: error: previous declaration of ‘strnlen’
> was here
> dulwich/_objects.c:30: error: conflicting types for ‘strnlen’
> /usr/include/string.h:143: error: previous declaration of ‘strnlen’
> was here
>  + d/_objects.c
>                                                               
> lipo: can't open input
> file: /var/folders/vx/4kr3q0s955n5kqxcc5c5j0xh0000gn/T//ccdwFWxq.out
> (No such file or directory)
> error: command '/usr/bin/cc' failed with exit status 1
> 
> 
> Remove the || defined(__APPLE__) and it builds fine on Lion but will
> obviously break on pre-Lion versions of OS X.
> 
> 
> I'm no friends with C so I have no idea how to patch that one but I
> figured you might.
I'm familiar with C, but not really aware of the names of the defines
involved on Mac OS X. Any Mac people around who can provide a patch?

Cheers,

Jelmer

Attachment: signature.asc
Description: This is a digitally signed message part