Fwd: "Formal" solution: parser.y:7: error: `stderr' undeclared (first use in this function)
I posted this to gnu.gcc.help, but it seems worth asking on this list as well. Particularly since it was strongly suggested by participants that I read this book. This is on SuSE 9.3. --------------- Forwarded message (begin) Subject: "Formal" solution: parser.y:7: error: `stderr' undeclared (first use in this function) From: Hattuari <susudata@setidava.kushan.aa> Date: Sat, 27 Aug 2005 00:16:10 -0400 Newsgroup: gnu.gcc.help I'm going through the Goat Book http://sources.redhat.com/autobook/, and when I followed the instructions on how to build the first example, I received the following message: Fri Aug 26 23:47:43:> make if gcc -DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE=\"foonly\" -DVERSION=\"1.0\" -DYYTEXT_POINTER=1 -I. -I. -g -O2 -MT parser.o -MD -MP -MF ".deps/parser.Tpo" -c -o parser.o parser.c; \ then mv -f ".deps/parser.Tpo" ".deps/parser.Po"; else rm -f ".deps/parser.Tpo"; exit 1; fi parser.y: In function `yyerror': parser.y:7: error: `stderr' undeclared (first use in this function) parser.y:7: error: (Each undeclared identifier is reported only once parser.y:7: error: for each function it appears in.) make: *** [parser.o] Error 1 I may (probably can) get this to compile by some trial and error. But that's why I'm reading the Goat Book! I've been using the other method for years, and I decided to start doing things right. Starting from scratch in §5.2 this is exactly what I did, and what was output: $ aclocal $ automake --add-missing configure.in: installing `./install-sh' configure.in: installing `./missing' Makefile.am: installing `./INSTALL' Makefile.am: required file `./NEWS' not found Makefile.am: required file `./README' not found Makefile.am: required file `./AUTHORS' not found Makefile.am: required file `./ChangeLog' not found Makefile.am: installing `./COPYING' Makefile.am: installing `./depcomp' # Hey, they told me to do it that way! $ touch NEWS README AUTHORS ChangeLog $ automake --add-missing $ ls AUTHORS Makefile.in configure main.c COPYING NEWS configure.in missing ChangeLog README depcomp nly.c INSTALL aclocal.m4 foo.c parser.y Makefile.am autom4te.cache install-sh scanner.l $ ./configure checking for a BSD-compatible install... /usr/bin/install -c checking whether build environment is sane... yes checking for gawk... gawk checking whether make sets $(MAKE)... yes checking for gcc... gcc checking for C compiler default output file name... a.out checking whether the C compiler works... yes checking whether we are cross compiling... no checking for suffix of executables... checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether gcc accepts -g... yes checking for gcc option to accept ANSI C... none needed checking for style of include used by make... GNU checking dependency style of gcc... gcc3 checking for flex... flex checking for yywrap in -lfl... yes checking lex output file root... lex.yy checking whether yytext is a pointer... yes checking for bison... bison -y configure: creating ./config.status config.status: creating Makefile config.status: executing depfiles commands $ make all if gcc -DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE=\"foonly\" -DVERSION=\"1.0\" -DYYTEXT_POINTER=1 -I. -I. -g -O2 -MT main.o -MD -MP -MF ".deps/main.Tpo" -c -o main.o main.c; \ then mv -f ".deps/main.Tpo" ".deps/main.Po"; else rm -f ".deps/main.Tpo"; exit 1; fi if gcc -DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE=\"foonly\" -DVERSION=\"1.0\" -DYYTEXT_POINTER=1 -I. -I. -g -O2 -MT foo.o -MD -MP -MF ".deps/foo.Tpo" -c -o foo.o foo.c; \ then mv -f ".deps/foo.Tpo" ".deps/foo.Po"; else rm -f ".deps/foo.Tpo"; exit 1; fi if gcc -DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE=\"foonly\" -DVERSION=\"1.0\" -DYYTEXT_POINTER=1 -I. -I. -g -O2 -MT nly.o -MD -MP -MF ".deps/nly.Tpo" -c -o nly.o nly.c; \ then mv -f ".deps/nly.Tpo" ".deps/nly.Po"; else rm -f ".deps/nly.Tpo"; exit 1; fi flex scanner.l sed '/^#/ s|lex.yy\.c|scanner.c|' lex.yy.c >scanner.c rm -f lex.yy.c if gcc -DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE=\"foonly\" -DVERSION=\"1.0\" -DYYTEXT_POINTER=1 -I. -I. -g -O2 -MT scanner.o -MD -MP -MF ".deps/scanner.Tpo" -c -o scanner.o scanner.c; \ then mv -f ".deps/scanner.Tpo" ".deps/scanner.Po"; else rm -f ".deps/scanner.Tpo"; exit 1; fi bison -y parser.y if test -f y.tab.h; then \ to=`echo "parser_H" | sed \ -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/' \ -e 's/[^ABCDEFGHIJKLMNOPQRSTUVWXYZ]/_/g'`; \ sed -e "/^#/!b" -e "s/Y_TAB_H/$to/g" -e "s|y\.tab\.h|parser.h|" \ y.tab.h >parser.ht; \ rm -f y.tab.h; \ if cmp -s parser.ht parser.h; then \ rm -f parser.ht ;\ else \ mv parser.ht parser.h; \ fi; \ fi if test -f y.output; then \ mv y.output parser.output; \ fi sed '/^#/ s|y\.tab\.c|parser.c|' y.tab.c >parser.ct && mv parser.ct parser.c rm -f y.tab.c if gcc -DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE=\"foonly\" -DVERSION=\"1.0\" -DYYTEXT_POINTER=1 -I. -I. -g -O2 -MT parser.o -MD -MP -MF ".deps/parser.Tpo" -c -o parser.o parser.c; \ then mv -f ".deps/parser.Tpo" ".deps/parser.Po"; else rm -f ".deps/parser.Tpo"; exit 1; fi parser.y: In function `yyerror': parser.y:7: error: `stderr' undeclared (first use in this function) parser.y:7: error: (Each undeclared identifier is reported only once parser.y:7: error: for each function it appears in.) make: *** [parser.o] Error 1 I have not tried to fix this yet. The reason I'm asking is not that I want the program to compile. I don't even know what it does. I want to know the _right_ way to solve these kinds of problems. Any suggestions? -- STH --------------- Forwarded message (end) -- Regards, Steven
"Steven T. Hatton" <hattons@globalsymmetry.com> writes:
I posted this to gnu.gcc.help, but it seems worth asking on this list as well. Particularly since it was strongly suggested by participants that I read this book. This is on SuSE 9.3. --------------- Forwarded message (begin)
Subject: "Formal" solution: parser.y:7: error: `stderr' undeclared (first use in this function) From: Hattuari <susudata@setidava.kushan.aa> Date: Sat, 27 Aug 2005 00:16:10 -0400 Newsgroup: gnu.gcc.help
I'm going through the Goat Book http://sources.redhat.com/autobook/, and when I followed the instructions on how to build the first example, I received the following message:
Fri Aug 26 23:47:43:> make if gcc -DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE=\"foonly\" -DVERSION=\"1.0\" -DYYTEXT_POINTER=1 -I. -I. -g -O2 -MT parser.o -MD -MP -MF ".deps/parser.Tpo" -c -o parser.o parser.c; \ then mv -f ".deps/parser.Tpo" ".deps/parser.Po"; else rm -f ".deps/parser.Tpo"; exit 1; fi parser.y: In function `yyerror': parser.y:7: error: `stderr' undeclared (first use in this function) parser.y:7: error: (Each undeclared identifier is reported only once parser.y:7: error: for each function it appears in.) make: *** [parser.o] Error 1
Add #include <stdio.h> The source file is broken if it misses that, Andreas -- Andreas Jaeger, aj@suse.de, http://www.suse.de/~aj SUSE Linux Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GPG fingerprint = 93A3 365E CE47 B889 DF7F FED1 389A 563C C272 A126
On Saturday 27 August 2005 09:55, Andreas Jaeger wrote:
"Steven T. Hatton" <hattons@globalsymmetry.com> writes:
I posted this to gnu.gcc.help, but it seems worth asking on this list as well. Particularly since it was strongly suggested by participants that I read this book. This is on SuSE 9.3. --------------- Forwarded message (begin)
Subject: "Formal" solution: parser.y:7: error: `stderr' undeclared (first use in this function) From: Hattuari <susudata@setidava.kushan.aa> Date: Sat, 27 Aug 2005 00:16:10 -0400 Newsgroup: gnu.gcc.help
I'm going through the Goat Book http://sources.redhat.com/autobook/, and when I followed the instructions on how to build the first example, I received the following message:
Fri Aug 26 23:47:43:> make if gcc -DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE=\"foonly\" -DVERSION=\"1.0\" -DYYTEXT_POINTER=1 -I. -I. -g -O2 -MT parser.o -MD -MP -MF ".deps/parser.Tpo" -c -o parser.o parser.c; \ then mv -f ".deps/parser.Tpo" ".deps/parser.Po"; else rm -f ".deps/parser.Tpo"; exit 1; fi parser.y: In function `yyerror': parser.y:7: error: `stderr' undeclared (first use in this function) parser.y:7: error: (Each undeclared identifier is reported only once parser.y:7: error: for each function it appears in.) make: *** [parser.o] Error 1
Add #include <stdio.h>
The source file is broken if it misses that,
Andreas
That's what I did, but I'm left wondering if that is what was intended. Did the authors intend that to somehow be automatically pasted in somehow? -- Regards, Steven
* Steven T. Hatton (hattons@globalsymmetry.com) [20050829 03:27]:
That's what I did, but I'm left wondering if that is what was intended. Did the authors intend that to somehow be automatically pasted in somehow?
No, this IMHO is just sloppy programming. Maybe the definition of stderr was somehow pulled in indirectly in former times, which won't work nowadys as glibc headers were carefully changed to only pull in what they really need and not complete headers. Philipp
No, this IMHO is just sloppy programming. Maybe the definition of stderr was somehow pulled in indirectly in former times, which won't work nowadys as glibc headers were carefully changed to only pull in what they really need and not complete headers. True. The ISO C and C++ standards define what gets defined in the specific
On Monday 29 August 2005 11:57 am, Philipp Thomas wrote: header files (in this case stdio.h). In this particular case, the offending file is parser.y, which is a yacc (bison) file that generates parser.c. the yyerror() function exists by default, but it is generally recommended that the user supply their own. The yacc(1) manpage has an example with #include <stdio.h>. -- Jerry Feldman <gaf@blu.org> Boston Linux and Unix user group http://www.blu.org PGP key id:C5061EA9 PGP Key fingerprint:053C 73EC 3AC1 5C44 3E14 9245 FB00 3ED5 C506 1EA9
On Monday 29 August 2005 11:57 am, Philipp Thomas wrote:
No, this IMHO is just sloppy programming. Maybe the definition of stderr was somehow pulled in indirectly in former times, which won't work nowadys as glibc headers were carefully changed to only pull in what they really need and not complete headers. It is possible (see my previous post) that they assumed that the yacc skeleton would pull in #include <stdio.h>. But on Linux, we use bison(1) which has a different skeleton.
(I fully agree that this is sloppy programming). -- Jerry Feldman <gaf@blu.org> Boston Linux and Unix user group http://www.blu.org PGP key id:C5061EA9 PGP Key fingerprint:053C 73EC 3AC1 5C44 3E14 9245 FB00 3ED5 C506 1EA9
participants (4)
-
Andreas Jaeger
-
Jerry Feldman
-
Philipp Thomas
-
Steven T. Hatton