Modify

Opened 7 years ago

Closed 6 years ago

Last modified 4 years ago

#9849 closed defect (fixed)

Compile on Mac OS X 10.7: getline.h

Reported by: Jakub Tymejczyk <tymmej@…> Owned by: developers
Priority: normal Milestone: Barrier Breaker 14.07
Component: toolchain Version: Trunk
Keywords: mac lion getline Cc:

Description

Mac OS X 10.7 Lion with Xcode 4.1
Trunk rev. 27839, first compilation

make[3]: Entering directory `/Volumes/OpenWrt/trunk/tools/genext2fs'
make[3]: Entering directory `/Volumes/OpenWrt/trunk/tools/patch-cmdline'
make -C /Volumes/OpenWrt/trunk/build_dir/host/genext2fs-1.4.1 CFLAGS="-O2 -I/Volumes/OpenWrt/trunk/staging_dir/host/include -include getline.h" all
make[3]: Entering directory `/Volumes/OpenWrt/trunk/tools/firmware-utils'
make  all-am
if gcc -DHAVE_CONFIG_H -I. -I. -I.     -O2 -I/Volumes/OpenWrt/trunk/staging_dir/host/include -include getline.h -MT genext2fs.o -MD -MP -MF ".deps/genext2fs.Tpo" -c -o genext2fs.o genext2fs.c; \
	then mv -f ".deps/genext2fs.Tpo" ".deps/genext2fs.Po"; else rm -f ".deps/genext2fs.Tpo"; exit 1; fi
In file included from <command-line>:0:0:
/Volumes/OpenWrt/trunk/staging_dir/host/include/getline.h:41:1: error: static declaration of 'getline' follows non-static declaration
/usr/include/stdio.h:449:9: note: previous declaration of 'getline' was here
make[3]: Leaving directory `/Volumes/OpenWrt/trunk/tools/patch-cmdline

/usr/include/stdio.h

...
/* Additional functionality provided by:
 * POSIX.1-2008
 */

#if __DARWIN_C_LEVEL >= 200809L
#ifndef _SSIZE_T
#define _SSIZE_T
typedef __darwin_ssize_t        ssize_t;
#endif

__BEGIN_DECLS
int dprintf(int, const char * __restrict, ...) __DARWIN_LDBL_COMPAT(dprintf) __printflike(2, 3) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3);
int vdprintf(int, const char * __restrict, va_list) __DARWIN_LDBL_COMPAT(vdprintf) __printflike(2, 0) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3);
ssize_t getdelim(char ** __restrict, size_t * __restrict, int, FILE * __restrict) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3);
ssize_t getline(char ** __restrict, size_t * __restrict, FILE * __restrict) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3); //line 449
__END_DECLS
#endif /* __DARWIN_C_LEVEL >= 200809L */
...

/Volumes/OpenWrt/trunk/staging_dir/host/include/getline.h

...
 * Copyright (c) 2006 SPARTA, Inc.
 * All rights reserved.
...
#ifndef __linux__
#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

/*
 * Emulate glibc getline() via BSD fgetln().
 * Note that outsize is not changed unless memory is allocated.
 */
static inline ssize_t
getline(char **outbuf, size_t *outsize, FILE *fp)
{
	size_t len;

#ifndef __CYGWIN__
	char *buf;
	buf = fgetln(fp, &len);
#else
	char buf[512];
	fgets(buf, sizeof(buf), fp);	
	len = strlen(buf);
#endif
	if (buf == NULL)
		return (-1);

	/* Assumes realloc() accepts NULL for ptr (C99) */
	if (*outbuf == NULL || *outsize < len + 1) {
		void *tmp = realloc(*outbuf, len + 1);
		if (tmp == NULL)
			return (-1);
		*outbuf = tmp;
		*outsize = len + 1;
	}
	memcpy(*outbuf, buf, len);
	(*outbuf)[len] = '\0';
	return (len);
}
#endif

The problem is that Lion introduced declaration of getline function in stdio.h, but without "static inline" modifiers.
Temporary fix is to comment out that line in /usr/include/stdio.h.

Attachments (0)

Change History (3)

comment:1 Changed 7 years ago by Jakub Tymejczyk <tymmej@…>

Changed by rev. 27916.
Shouldn't the type of function be independent from the host system?

comment:2 Changed 6 years ago by nico

  • Resolution set to fixed
  • Status changed from new to closed

Fixed in r27916

comment:3 Changed 4 years ago by jow

  • Milestone changed from Attitude Adjustment 12.09 to Barrier Breaker 14.07

Milestone Attitude Adjustment 12.09 deleted

Add Comment

Modify Ticket

Action
as closed .
The resolution will be deleted. Next status will be 'reopened'.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.