Compiling C ++ code using gnu / c getline () on mac osx?

I am trying to compile an existing C ++ package on my Mac OS x leopard computer and get the following error:

    error: no matching function for call to 'getline (char **, size_t *, FILE * &)'

This is probably due to the fact that getline () is a GNU extension.

Can I somehow make the default gs compiler osx recognize such GNU extensions by default?

(if not, I can always provide my own implementation or the original version of GNU, but if possible, I prefer to have a "cleaner" solution)

+2
source share
3 answers

getline stdio.h glibc 2.10 , , ( 10.5 getline 10.7 ) BSD, libc.

GNU - POSIX 2008, getline.

, libc . , , .

GNU.

+5

, autoconf - , getline , , .

:

# configure.ac
AC_CHECK_FUNCS([getline])

// compat.h
#include "config.h"
#ifndef HAVE_GETLINE
ssize_t getline(char **lineptr, size_t *n, FILE *stream);
#endif

// getline.c
ssize_t getline(char **lineptr, size_t *n, FILE *stream) {
    /* definition */
}

# Makefile.am
program_LDADD = $(if $(HAVE_GETLINE),,getline.o)

- , .

+1
0

Source: https://habr.com/ru/post/1774422/


All Articles