Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: stdin/stdout



Okay, upon further investigation, I've discovered that the tests are only meant to be run by the developers of flex (and that most if not all of the errors stem from failing to include <stdint.h>). As for the assigning to stdin and stdout, I removed those sections entirely since before doing that dup2 was being called to set the file descriptor and I believe that that is sufficient (correct?).

I suppose the only question that remains is why stdin and friends are defined as they are rather than as FILE*s.

- Steve
On May 22, 2004, at 9:03 PM, Steve Checkoway wrote:

I was attempting to compile the latest version of flex, 2.5.31, when it failed with three errors. All three had to do with invalid lvalues so I opened up filter.c (the offending file) and checked the lines. They were of the form:
if ((stdin = fdopen(0, "r") == NULL)

Since I had just successfully compiled this version on linux, I decided to open /usr/include/stdio.h to see just how stdin and stdout were defined. Here is what I found:
#define stdin (&__sF[0])
#define stdout (&__sF[1])
#define stderr (&__sF[2])

I checked the stdio.h file on the linux computer to see what it contained. It had:
extern FILE *stdin; /* Standard input stream. */
extern FILE *stdout; /* Standard output stream. */
extern FILE *stderr; /* Standard error output stream. */
#ifdef __STDC__
/* C89/C99 say they're macros. Make them happy. */
#define stdin stdin
#define stdout stdout
#define stderr stderr
#endif

I suspected that changing stdin/stdout in the lines that were failing to fp = fdopen... where fp was a FILE* and then adding an else clause of memcpy(stdin, fp, sizeof(FILE)) would be a bad idea but I went ahead and tried it. 5 tests failed when I ran make check (and then 4 subsequent times...) so I don't know if the problem is unrelated or if I was correct and that really was a bad idea.

After all that background, I suppose my questions are:
1) Is there a reason to make stdin, stdout, and stderr be addresses of a FILE rather than a FILE*?
2) How should I hack around the assignment to stdin/stdout?

Thanks,

Steve Checkoway
_______________________________________________
darwin-development mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/darwin-development
Do not post admin requests to the list. They will be ignored.
_______________________________________________
darwin-development mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/darwin-development
Do not post admin requests to the list. They will be ignored.


References: 
 >stdin/stdout (From: Steve Checkoway <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.