🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.help
Article #42686

Re: Undeclared variables compiling groff with gcc 2.7.0

#42686
From: bill wagner
Date: Thu, 09 Nov 1995 00:00
66 lines
2692 bytes
Robert Gagnon (lonas@jrv.qc.ca) wrote:
: Hi.

: I am attempting to compile groff 1.09 with gcc 2.7.0.

: The compilation aborts with undeclared variables in some file.

: I edit the file, then will see something like:

: for (int i=0; i<10; i++) {
: ...
: }
: ...
: i = 2;

: When a definition is inside a loop expression (for or while), the compiler
: assumes that the scope of the variable is the body of the loop.

: The problem is the groff programmer assumed the scope of the variable would be 
: the block containing the loop.

: Is there a way to make gcc behave that way?  I am tiring of editing files...

: Thanks.

I'm just getting around to trying this and ran into the same problem. When I
didn't see an answer here I looked through my gcc-2.7.0 dir and found in the
gcc-2.7.0/NEWS file:


	The scope of variables declared in the for-init-statement has been changed
	to conform to http://www.cygnus.com/~mrs/wp-draft/stmt.html#stmt.for; as a
	result, packages such as groff 1.09 will not compile unless you specify the
	-fno-for-scope flag.  PLEASE DO NOT REPORT THIS AS A BUG; this is a change
	mandated by the C++ standardization committee.

'make "CCC=gcc -fno-for-scope' seems to do the trick!

BTW, now I get the error:

	string.cc: In method `int string::search(char) const':
	string.cc:273: call of overloaded `memchr' is ambiguous
	/usr/gnu/lib/g++-include/std/cstring.h:61: candidates are: memchr(void *, int, l
	ong unsigned int)
	/usr/gnu/lib/g++-include/std/cstring.h:58:                 memchr(const void *, 
	int, long unsigned int)
	*** Error code 1

which I am patching by casting to a specific memchr, as in changing:

	char *p = (char *)memchr(ptr, c, len);

to

	char *p = (char *)memchr((void *)ptr, c, len);

This seems to be working also ... right now it's cranking out those compiles.
	 

- wcw

 =======  ---------------------------------------------------- =======
 =|_=|_=  Bill Wagner               ||  Hughes Aircraft, RCSS  =|_=|_=
 =|_=|_=  wwagner@hac2arpa.hac.com  ||  El Segundo, CA         =|_=|_=
 =======  ---------------------------------------------------- =======
   Opinions expressed are mine, but they can be yours if you act now!
Technical Details
Message-ID: <47rior$390@hacgate2.hac.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <47dbb2$9oc@wagner.spc.videotron.ca>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 11318c,6824576630e2f5f2,start
X-Google-Attributes: gid11318c,public
From: wagner@rasbora.es.hac.com ( bill wagner)
Subject: Re: Undeclared variables compiling groff with gcc 2.7.0
Date: 1995/11/09
Message-ID: <47rior$390@hacgate2.hac.com>
X-Deja-AN: 118940588
references: <47dbb2$9oc@wagner.spc.videotron.ca>
organization: Hughes Aircraft Company
newsgroups: gnu.gcc.help