🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #2123

file *yyin=stdin; not

#2123
From: "chris perkins"
Date: Mon, 12 Oct 1992 13:10
46 lines
1487 bytes
Organization: Canada Remote Systems

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: <719058360.F00017@monly.wlink.nl.wlink.nl>
Path: arc1-ca.pugleaf.net!sparky!uunet!mcsun!sun4nl!wtrlnd!monly.wlink.nl!news-daemon

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!mcsun!sun4nl!wtrlnd!monly.wlink.nl!news-daemon
From: "chris.perkins"@f1.n100.z60.wlink.nl ("chris perkins")
Newsgroups: comp.std.c
Subject: file *yyin=stdin; not
Message-ID: <719058360.F00017@monly.wlink.nl.wlink.nl>
Date: Mon, 12 Oct 1992 12:10:43 -0100
Sender: news-daemon@monly.wlink.nl.wlink.nl
Lines: 47