[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Why does stdio.h have to be included before readline/readline.h (ins

From: Chet Ramey
Subject: Re: Why does stdio.h have to be included before readline/readline.h (installed via homebrew) on macOS?
Date: Wed, 19 May 2021 14:18:37 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.10.1

On 5/19/21 1:11 PM, Peng Yu wrote:
But on Linux, stdio.h is not needed. Can't the behavior be made the
same on Linux and macOS?

If you would like Apple to change its header files so that you don't need
stdio.h for stdio definitions, or string.h for strcmp(), file a bug report
with Apple.

Or you could include <stdio.h> as the readline documentation recommends
(and string.h for the strcmp prototype).

Historically, stdio.h is where you found definitions for NULL and EOF. If
you wanted to write something like

while ((line = readline ("prompt> ")) != NULL)

as many programs do -- including yours -- you needed it.

In your case, it doesn't matter whether or not your program includes stdio.h on macOS. It doesn't compile because it doesn't include string.h,

$ clang --version
Apple clang version 12.0.0 (clang-1200.0.32.29)
Target: x86_64-apple-darwin19.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://tiswww.cwru.edu/~chet/

reply via email to

[Prev in Thread] Current Thread [Next in Thread]