# strbuf name conflict on Mac OS

5 messages from 2009-03-31 to 2009-03-31. Participants: Joshua Juran, Johannes Schindelin, Brian Gernhardt, Jay Soffian.
Thread: https://gitlist.dev/t/18672

## Joshua Juran, 2009-03-31 20:17

Subject: strbuf name conflict on Mac OS
Message-ID: <E5D92A5D-B2CC-44CE-B117-0BB88C0E663E@gmail.com>
URL: https://gitlist.dev/e/E5D92A5D-B2CC-44CE-B117-0BB88C0E663E%40gmail.com

```
Apple's OpenTransport.h from Universal Interfaces 3.4.2 defines its  
own struct strbuf, with which git's collides.

Since OpenTransport.h also defines some POSIX constants (such as  
O_NONBLOCK) as enums, it's necessary to include OpenTransport.h from  
fcntl.h (and other affected headers) so as to control the order in  
which the definitions appear in the translation unit.

This is the minimal patch:


diff --git a/strbuf.h b/strbuf.h
index 89bd36e..b8f380e 100644
--- a/strbuf.h
+++ b/strbuf.h
@@ -40,6 +40,8 @@

  #include <assert.h>

+#define strbuf git_strbuf
+
  extern char strbuf_slopbuf[];
  struct strbuf {
         size_t alloc;


Josh

```

## Johannes Schindelin, 2009-03-31 20:24

Subject: Re: strbuf name conflict on Mac OS
Message-ID: <alpine.DEB.1.00.0903312222440.6616@intel-tinevez-2-302>
URL: https://gitlist.dev/e/alpine.DEB.1.00.0903312222440.6616%40intel-tinevez-2-302
In-Reply-To: <E5D92A5D-B2CC-44CE-B117-0BB88C0E663E@gmail.com>

```
Hi,

On Tue, 31 Mar 2009, Joshua Juran wrote:

> Apple's OpenTransport.h from Universal Interfaces 3.4.2 defines its own struct
> strbuf, with which git's collides.
> 
> Since OpenTransport.h also defines some POSIX constants (such as O_NONBLOCK)
> as enums, it's necessary to include OpenTransport.h from fcntl.h (and other
> affected headers) so as to control the order in which the definitions appear
> in the translation unit.
> 
> This is the minimal patch:
> 
> 
> diff --git a/strbuf.h b/strbuf.h
> index 89bd36e..b8f380e 100644
> --- a/strbuf.h
> +++ b/strbuf.h
> @@ -40,6 +40,8 @@
> 
> #include <assert.h>
> 
> +#define strbuf git_strbuf
> +
> extern char strbuf_slopbuf[];
> struct strbuf {
>        size_t alloc;

How about this instead?

-- snip --
diff --git a/Makefile b/Makefile
index 32d6782..370c2d9 100644
--- a/Makefile
+++ b/Makefile
@@ -659,6 +659,7 @@ ifeq ($(uname_S),SCO_SV)
 	TAR = gtar
 endif
 ifeq ($(uname_S),Darwin)
+	BASIC_CFLAGS += -Dstrbuf=git_strbuf
 	NEEDS_SSL_WITH_CRYPTO = YesPlease
 	NEEDS_LIBICONV = YesPlease
 	ifeq ($(shell expr "$(uname_R)" : '[15678]\.'),2)
-- snap --

No need to let other platforms (and the C source) suffer...

Ciao,
Dscho

```

## Brian Gernhardt, 2009-03-31 20:26

Subject: Re: strbuf name conflict on Mac OS
Message-ID: <5ECAAD78-F8D4-4F86-A16B-C8DF483771D6@silverinsanity.com>
URL: https://gitlist.dev/e/5ECAAD78-F8D4-4F86-A16B-C8DF483771D6%40silverinsanity.com
In-Reply-To: <E5D92A5D-B2CC-44CE-B117-0BB88C0E663E@gmail.com>

```

On Mar 31, 2009, at 4:17 PM, Joshua Juran wrote:

> Apple's OpenTransport.h from Universal Interfaces 3.4.2 defines its  
> own struct strbuf, with which git's collides.
>
> Since OpenTransport.h also defines some POSIX constants (such as  
> O_NONBLOCK) as enums, it's necessary to include OpenTransport.h from  
> fcntl.h (and other affected headers) so as to control the order in  
> which the definitions appear in the translation unit.

Just to be clear, this is related to your work on LAMP under Classic  
and not OS X, correct?  If so, perhaps you need to create a compat/ 
classic_mac.h file that's included (when the correct #defines are  
seen) from git-compat-util.h in the manner of compat/ 
{cygwin,mingw}.h.  I'm assuming that this naming conflict is not the  
only such you'll find and it's better to keep platform specific tweaks  
to a single place when possible.

~~ Brian

```

## Jay Soffian, 2009-03-31 21:36

Subject: Re: strbuf name conflict on Mac OS
Message-ID: <76718490903311436p5fe81ce3k31f18170d9388e8e@mail.gmail.com>
URL: https://gitlist.dev/e/76718490903311436p5fe81ce3k31f18170d9388e8e%40mail.gmail.com
In-Reply-To: <alpine.DEB.1.00.0903312222440.6616@intel-tinevez-2-302>

```
On Tue, Mar 31, 2009 at 4:24 PM, Johannes Schindelin
<Johannes.Schindelin@gmx.de> wrote:
> How about this instead?
>  ifeq ($(uname_S),Darwin)
> +       BASIC_CFLAGS += -Dstrbuf=git_strbuf

Heh, wrong platform. See Joshua's other message about porting git to
Mac OS (not Mac OS X). :-)

j.

```

## Joshua Juran, 2009-03-31 21:57

Subject: Re: strbuf name conflict on Mac OS
Message-ID: <B21DA82F-5057-4C78-8400-1CEE5D4E8078@gmail.com>
URL: https://gitlist.dev/e/B21DA82F-5057-4C78-8400-1CEE5D4E8078%40gmail.com
In-Reply-To: <76718490903311436p5fe81ce3k31f18170d9388e8e@mail.gmail.com>

```
On Mar 31, 2009, at 2:36 PM, Jay Soffian wrote:

> On Tue, Mar 31, 2009 at 4:24 PM, Johannes Schindelin
> <Johannes.Schindelin@gmx.de> wrote:
>> How about this instead?
>>  ifeq ($(uname_S),Darwin)
>> +       BASIC_CFLAGS += -Dstrbuf=git_strbuf
>
> Heh, wrong platform. See Joshua's other message about porting git to
> Mac OS (not Mac OS X). :-)

That, and I'm not using make.  There's no need for this to be any  
more painful than necessary.  :-)

I've added compat/lamp.h, following Brian's suggestion.

Josh

```
