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



On May 22, 2004, at 21:03, 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)

Oddly, this very subject just came up on the unix-porting list. You may want to check the archives for details (the thread is "Another C++ question").

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*?

Yup; that's the way FreeBSD did it in the code bases that Apple has imported. This is known as a problem, and is slated to be fixed (as FreeBSD eventually did), in the Famous Future Release.

2) How should I hack around the assignment to stdin/stdout?

The suggested workaround was something along the lines of
FILE *temp = fopen(inputFilename,"r");
dup2(temp->_file ,STDIN_FILENO);
fclose(temp);

(in my case, freopen() was the culprit, in exactly the same usage as your 'fdopen'. You should be able to come up with a similar hack, until the real thing comes along.

Regards,

Justin

--
Justin C. Walker, Curmudgeon-At-Large *
Institute for General Semantics | When LuteFisk is outlawed
| Only outlaws will have
| LuteFisk
*--------------------------------------*-------------------------------*
_______________________________________________
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.