Alternative for getline() function in AIX 5.3
Omer Zak
w1 at zak.co.il
Tue Jul 27 14:08:06 IDT 2010
DISCLAIMER:
1. I don't have access to AIX.
2. I didn't actually test my suggestions.
Alternatives:
1. Use fgets() if it is available for AIX, too.
2. According to man getline, getline() is a GNU extension, and is
available only when you #define _GNU_SOURCE.
So use:
#ifdef __GNUC__
// use getline()
#else /* __GNUC__ */
// use gets() or fgets()
#endif /* __GNUC__ */
3. Same as (2) but test __USE_POSIX instead of __GNUC__
On Tue, 2010-07-27 at 13:15 +0300, Israel Shikler wrote:
> Hi,
>
> I have a C program that reads one line of text from the keyboard.
>
> The original program was written 10 years ago and was compiled with cc
> on AIX 4.x.
> I used the gets() function which was the only option available at the
> time.
>
> Recently, I had to port the program to gcc on Linux, but I was
> confronted with lots of segfaults.
> So, I had to change the function to getline() which is much more
> stable and secure.
>
> However, I was asked to maintain the new version on AIX 5.3 as well.
>
> When recompiling the program on the AIX machine I was confronted with
> the lack of getline() in AIX implementation of cc.
> I do not have gcc on that machine, and installing it would be an
> option of last resort .
>
> I am looking for an alternative to getline(), that would be portable
> to both Linux and AIX.
--
"Kosher" Cellphones (cellphones with blocked SMS, video and Internet)
are menace to the deaf. They must be outlawed!
(See also: http://www.zak.co.il/tddpirate/2006/04/21/the-grave-danger-to-the-deaf-from-kosher-cellphones/ and http://www.zak.co.il/tddpirate/2007/02/04/rabbi-eliashiv-declared-war-on-the-deaf/)
My own blog is at http://www.zak.co.il/tddpirate/
My opinions, as expressed in this E-mail message, are mine alone.
They do not represent the official policy of any organization with which
I may be affiliated in any way.
WARNING TO SPAMMERS: at http://www.zak.co.il/spamwarning.html
More information about the Linux-il
mailing list