Apple Intelligence is now available on iPhone, iPad, and Mac!

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Documentation on Apple's Clang/Stdio.h on MacOS

in xCode V12.1 (Catalina) using C, the compiler pre-processor substitutes Darwin.C.stdio for stdio.h in the code below, which I believe is correct, but when run, it does nothing and returns an Exit Code 9 and remains running... looking for any documentation of getchar/putchar in Darwin.C.stdio.h


#pragma clang module import Darwin.C.stdio /* clang -E: implicit import for #include <stdio.h> */

int main(int argc, const char * argv[])

    {

        int c;

        c = getchar();

        while ( c != (-1)) { // while ( (c=getchar() ) != EOF ) also doesn't work

            putchar(c);

            c = getchar();

        }

        return 0;


    }

MacBook Pro 13″, macOS 10.15

Posted on Oct 30, 2020 4:08 AM

Reply
7 replies

Oct 31, 2020 1:55 PM in response to bobscott

bobscott wrote:

The C compiler pre-processor in Xcode inserts the new studio.h and comments out my stdio.h. The program is just reading/writing from/to keyboard. It’s a skeleton for a bigger pigment I’m just starting

Sorry, but I have no idea what you are talking about. I even looked at the pre-processor output. There are no pragmas in there. Why are you even screwing around with preprocessor output anyway?

Nov 1, 2020 5:43 AM in response to etresoft

xCode was set for Command Line and the compiler was C... the 'main (arc, argv)' may have been syntactically correct but as soon as I commented it out, saved, and hit RUN, I got a successful build, the pragma issue disappeared in the code displayed, and the program behaved as expected... thanks for sticking with me on this one... very much appreciated

Documentation on Apple's Clang/Stdio.h on MacOS

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.