I have some old C code (originally written for linux) that I'm trying to compile on osx. I don't have a lot of experience with big C programs; there's no documentation, and the devs are all gone away, so I've been struggling with it --- anyway, when I try to make, it gives the following errors before crapping out:
dprintf.h:16: error: parse error before 'saferead'
dprintf.h:16: warning: type defaults to 'int' in declaration of 'saferead'
dprintf.h:16: warning: data definition has no type or storage class
dprintf.h:17: error: parse error before 'safewrite'
dprintf.h:17: warning: type defaults to 'int' in declaration of 'safewrite'
dprintf.h:17: warning: data definition has no type or storage class
make[2]: *** [dperc.o] Error 1
rm DDataDescrip.o
make[1]: *** [dprintf] Error 2
make: *** [all] Error 255
Here's the offending header file. It looks okay to me, but maybe someone more experienced here will spot something amiss:
#ifndef _DPRINTF_H
#define _DPRINTF_H
#include "dprintf/dprintf_defs.h"
/*
* This file was automatically generated by version 1.7 of cextract.
* Manual editing not recommended.
*
* Created: Sat Jan 26 19:07:06 2008
*/
#ifndef __CEXTRACT__
#if __STDC__
extern int dperc ( int dbl );
extern void dprintf ( short dlevel, char *fmt, ... );
extern __inline ssize_t saferead ( int fd, void *buf, size_t count );
extern __inline ssize_t safewrite ( int fd, void *buf, size_t count );
#endif /* __STDC__ */
#endif /* __CEXTRACT__ */
/*
* This part was generated from DDataDescrip.c
* Sat Jan 26 19:07:05 GMT 2008
*/
extern short debug_level;
extern int perc_tot;
extern int perc_num;
extern long n_alloc;
#endif /* _DPRINTF_H */
"__inline" is not a C keyword.
Replace __inline with inline and compile with -std=C99.
gcc recognizes __inline with or without -std=c99
you forgot to #include the header for ssize_t
<unistd.h>
or
<sys/types.h>
Also, if your implementation does not provide ssize_t do
typedef long ssize_t;