Skip to contentSkip to conversation

imap-send.c fails to build on OSX

BUG Randal L. Schwartz 2 participants 5 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

gcc -o imap-send.o -c -g -O2 -Wall -I/sw/include -I/opt/local/include -DSHA1_HEADER='<openssl/sha.h>' imap-send.c imap-send.c:376: error: static declaration of 'vasprintf' follows non-static declaration /usr/include/stdio.h:297: error: previous declaration of 'vasprintf' was here
make: *** [imap-send.o] Error 1

Signature · 4 lines
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<[email protected]> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
#1 lore raw

Workarounds for compiling on MacOS X.

---

Quoted 5 lines · Randal L. Schwartz

gcc -o imap-send.o -c -g -O2 -Wall -I/sw/include -I/opt/local/include -DSHA1_HEADER='<openssl/sha.h>' imap-send.c imap-send.c:376: error: static declaration of 'vasprintf' follows non-static declaration /usr/include/stdio.h:297: error: previous declaration of 'vasprintf' was here
make: *** [imap-send.o] Error 1

This should fix the build issues on Mac OS X. Not tested on other (possibly) more important platforms, like Linux. :-)

 generate-cmdlist.sh |    2 +-
 imap-send.c         |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

base 57f4a482a7fc31e31cafd31fe23f4a4779b2c2f0
last 6854050e1cdaf1b7ab352e1d4757ff5b29a5db93

generate-cmdlist.sh +1 -1
index 6ee85d5..76ba49c 100755
@@ -42,7 +42,7 @@ EOF
 while read cmd
 do
     sed -n "/NAME/,/git-$cmd/H;
-	    \$ {x; s/.*git-$cmd - \\(.*\\)/  {\"$cmd\", \"\1\"},/; p}" \
+	    \$ {x; s/.*git-$cmd - \\(.*\\)/  {\"$cmd\", \"\1\"},/; p;}" \
 	"Documentation/git-$cmd.txt"
 done
 echo "};"
imap-send.c +1 -1
index fddaac0..376929f 100644
@@ -370,7 +370,7 @@ free_generic_messages( message_t *msgs )
 	}
 }
 
-static int
+int
 vasprintf( char **strp, const char *fmt, va_list ap )
 {
 	int len;
Signature · 1 line
1.2.4.g806b
#2 lore raw
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Shawn" == Shawn Pearce <[email protected]> writes:

Shawn> Workarounds for compiling on MacOS X. Shawn> Signed-off-by: Shawn O. Pearce <[email protected]>

Shawn> This should fix the build issues on Mac OS X. Not tested on other Shawn> (possibly) more important platforms, like Linux. :-)

My C is a bit rusty, but wouldn't that provide a definition for vasprintf when the libc is *also* providing a definition? Might that not also break other apps that want to link with this?

Maybe the right solution is to rename this local implementation so that it can't conflict, like "git_vasprintf", or to include it only when the libc doesn't provide it.

Signature · 4 lines
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<[email protected]> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
#3 lore raw
Quoted 8 lines · Randal L. Schwartz
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Shawn" == Shawn Pearce <[email protected]> writes:

Shawn> Workarounds for compiling on MacOS X. Shawn> Signed-off-by: Shawn O. Pearce <[email protected]>

Shawn> This should fix the build issues on Mac OS X. Not tested on other Shawn> (possibly) more important platforms, like Linux. :-)

Quoted 7 lines

My C is a bit rusty, but wouldn't that provide a definition for vasprintf when the libc is *also* providing a definition? Might that not also break other apps that want to link with this?

Maybe the right solution is to rename this local implementation so that it can't conflict, like "git_vasprintf", or to include it only when the libc doesn't provide it.

Your right. But I figured it wasn't a big deal since this is just an application and not library code. Nobody should be linking against it.

Perhaps the better solution is to rename the provided implementation to git_; maybe even better to move it off to the compat library area where other should-have-been-provided-by-the-OS definitions are.

Signature · 1 line
Shawn.
#4 lore raw
In reply to Randal L. Schwartz
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Randal" == Randal L Schwartz <[email protected]> writes:

Randal>     gcc -o imap-send.o -c -g -O2 -Wall -I/sw/include -I/opt/local/include -DSHA1_HEADER='<openssl/sha.h>'  imap-send.c
Randal>     imap-send.c:376: error: static declaration of 'vasprintf' follows non-static declaration
Randal>     /usr/include/stdio.h:297: error: previous declaration of 'vasprintf' was here
Randal>     make: *** [imap-send.o] Error 1

By the way, /usr/include/stdio.h near the line in question looks like:

int vasprintf(char **, const char *, va_list) __DARWIN_LDBL_COMPAT(vasprintf);

Signature · 4 lines
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<[email protected]> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!