Path: csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: Even more problems with lcc-win Date: Fri, 24 Mar 2017 16:27:04 -0700 Organization: None to speak of Lines: 49 Message-ID: References: <87vaqyvqzb.fsf@bsb.me.uk> <0b965946-ab59-43b6-8a95-6e224b9d40c7@googlegroups.com> <16b91e7c-08c8-4fad-b072-41fbdeea615e@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx02.eternal-september.org; posting-host="8a7136a2a556fadb85eac0a5973ae8a0"; logging-data="26956"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18N+PeU4UKfUgr0Q7tR1Wwj" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:0OSgymgBaD1b2IexsTZ9ZJLnAoM= sha1:Z5YzKJAAd9A/5m6N8QxVmRGlueM= Xref: csiph.com comp.lang.c:107015 supercat@casperkitty.com writes: > On Friday, March 24, 2017 at 5:44:04 PM UTC-5, Bart wrote: >> But I haven't yet managed to get hold of stdin/stdout which are >> surprisingly difficult when no C headers are involved. > > What does the Standard require of those? I would think that on some platforms > it would be most useful to say > > FILE stdin[1]; > > and on some it would be more helpful to say: > > FILE *stdin = (FILE*)&stdin_descriptor; > > while others might use something like: > > FILE *stdin = (FILE*)1; // Dummy address that won't identify a real object > > Would the Standard forbid any of those (bearing in mind that the first would > require that headers declare stdin as FILE[], while the others would need it > to be declared as FILE*)? I could certainly imagine situations where each > could be superior. stdin, stdout, and stderr are required to be macros, so you'd additionally need something like: #define stdin stdin #define stdout stdout #define stderr stderr (GNU libc does this.) Your first suggestion: FILE stdin[1]; would be non-conforming, since stdin is required to expand to an expression of type FILE*. Making FILE an incomplete type is a mildly interesting idea, but some stdio functions are commonly defined as macros that access the members of the FILE object. They'd have to use pointer casts to some complete type. -- Keith Thompson (The_Other_Keith) kst-u@mib.org Working, but not speaking, for JetHead Development, Inc. "We must do something. This is something. Therefore, we must do this." -- Antony Jay and Jonathan Lynn, "Yes Minister"