When <limits.h> does not define LINE_MAX , look at _POSIX2_LINE_MAX , which should be at least 2048. I usually use 4096.
Also look for the (new) POSIX functions getline() and getdelim() - both with the same URL. If necessary, they allocate memory.
Program ( posix2_line_max.c )
#include "posixver.h" #include <limits.h> #include <stdio.h> int main(void) { printf("%d\n", _POSIX2_LINE_MAX); return 0; }
Conclusion:
2048
posixver.h
#ifndef JLSS_ID_POSIXVER_H #define JLSS_ID_POSIXVER_H #if !defined(_XOPEN_SOURCE) && !defined(_POSIX_C_SOURCE) #if __STDC_VERSION__ >= 199901L #define _XOPEN_SOURCE 600 #else #define _XOPEN_SOURCE 500 #endif #endif #endif
Tested on derived Ubuntu 12.04; command line:
gcc -g -O3 -std=c99 -Wall -Wextra -Wmissing-prototypes -Wstrict-prototypes -Werror posix2_line_max.c -o posix2_line_max
source share