🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #2115

file *yyin=stdin; not

#2115
From: chris perkins
Date: Mon, 12 Oct 1992 15:10
45 lines
1498 bytes
TO:emmerik@utwente.nl

EP>The following looks to me perfectly legal ANSI-C code.

EP>sgi-cad> cat test.c
EP># include <stdio.h>
EP>FILE *yyin = {stdin}, *yyout = {stdout};
EP>main()
EP>{
EP>}

EP>Nevertheless i get the following results when compiling on a
EP>Silicon Graphics workstation:

EP>sgi-cad> cc -cckr test.c
EP>sgi-cad> cc -ansi test.c
EP>accom: Error: test.c, line 2: integer constant expected
EP>       FILE *yyin = {   (__stdin) }, *yyout = { (__stdout) };
EP>       ---------------------------^

The problem is that stdin and stdout are not constant pointers, but
are macros which get replaced by function calls (it may be compiler
dependant, I'm not sure of the standard).  I think the following
would work:

#include <stdio.h>
FILE *yyin, *yyout;
main()
{
   ...
   yyin = stdin;
   yyout = stdout;
   ...
}

Check your stdio.h to see how stdin and stdout are defined.

Regards,

Chris
---
 þ DeLuxeý/386 1.25 #9629 þ Best wishes,         Chris Perkins
--
Canada Remote Systems  - Toronto, Ontario
World's Largest PCBOARD System - 416-629-7000/629-7044
Technical Details
Message-ID: <1992Oct12.4502.4263@dosgate>
Path: arc1-ca.pugleaf.net!sparky!uunet!uunet.ca!unixbox!dosgate!dosgate![chris.perkins@canrem.com]

Show Full Headers
Complete Article Headers
Newsgroups: comp.std.c
Path: arc1-ca.pugleaf.net!sparky!uunet!uunet.ca!unixbox!dosgate!dosgate![chris.perkins@canrem.com]
From: "chris perkins" <chris.perkins@canrem.com>
Subject: file *yyin=stdin; not
Message-ID: <1992Oct12.4502.4263@dosgate>
Reply-To: "chris perkins" <chris.perkins@canrem.com>
Organization: Canada Remote Systems
Distribution: comp
Date: 12 Oct 92 10:10:43 EST
Lines: 45