public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* cpp doesn't define symbol i386
@ 1997-10-11 14:26 Ronald.Wahl
  1997-10-13 11:12 ` Jeffrey A Law
  0 siblings, 1 reply; 10+ messages in thread
From: Ronald.Wahl @ 1997-10-11 14:26 UTC (permalink / raw)
  To: egcs

Hi,

I noticed that cpp does not define the symbol i386 anymore. But this
symbol is necessary for xmkmf/imake under X. Now imake will not detect
that it is running on a i386 architecture. I see that that the defines
are in the spec-File but this isn't read bei cpp :-(.
As a dirty hack I have written a wrapper for imake but this can't be the
right solution. Any suggestions?

thx,
ron

-- 
\ Ronald Wahl --- rwa@informatik.tu-chemnitz.de   \
 \ WWW: http://www.tu-chemnitz.de/~row             \
  \ Talk: rwa@goliath.csn.tu-chemnitz.de            \
   \ PGP key available by finger to my email address \



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: cpp doesn't define symbol i386
  1997-10-11 14:26 cpp doesn't define symbol i386 Ronald.Wahl
@ 1997-10-13 11:12 ` Jeffrey A Law
  1997-10-13 15:02   ` Jim Wilson
  0 siblings, 1 reply; 10+ messages in thread
From: Jeffrey A Law @ 1997-10-13 11:12 UTC (permalink / raw)
  To: Ronald.Wahl; +Cc: egcs

  In message <Pine.LNX.3.96.971011231231.26729B-100000@goliath.csn.tu-chemnitz.
de>you write:
  > I noticed that cpp does not define the symbol i386 anymore. But this
  > symbol is necessary for xmkmf/imake under X.
As far as I can tell i386 should still be defined.  Can you investigate
why it's not being defined?
jeff

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: cpp doesn't define symbol i386
  1997-10-13 11:12 ` Jeffrey A Law
@ 1997-10-13 15:02   ` Jim Wilson
  1997-10-13 18:42     ` Ronald.Wahl
  0 siblings, 1 reply; 10+ messages in thread
From: Jim Wilson @ 1997-10-13 15:02 UTC (permalink / raw)
  To: law; +Cc: Ronald.Wahl, egcs

	As far as I can tell i386 should still be defined.  Can you investigate
	why it's not being defined?

i386 is defined only if you use `gcc -E'.  This person is complaining that
it is not defined if you use `cpp'.  I think the answer here is to tell people
that they can't rely on using `cpp' for preprocessing stuff that isn't C code,
but if they really want to use it, then they should use `gcc -E' (or maybe
even `gcc -E -traditional') instead of just `cpp'.

Jim

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: cpp doesn't define symbol i386
  1997-10-13 15:02   ` Jim Wilson
@ 1997-10-13 18:42     ` Ronald.Wahl
  1997-10-14  1:23       ` Ronald.Wahl
  0 siblings, 1 reply; 10+ messages in thread
From: Ronald.Wahl @ 1997-10-13 18:42 UTC (permalink / raw)
  To: Jim Wilson; +Cc: law, egcs

On Mon, 13 Oct 1997, Jim Wilson wrote:

> 	As far as I can tell i386 should still be defined.  Can you investigate
> 	why it's not being defined?
> 
> i386 is defined only if you use `gcc -E'.  This person is complaining that
> it is not defined if you use `cpp'.  I think the answer here is to tell people
> that they can't rely on using `cpp' for preprocessing stuff that isn't C code,
> but if they really want to use it, then they should use `gcc -E' (or maybe
> even `gcc -E -traditional') instead of just `cpp'.

Hmm, now I replaced /lib/cpp by a script which calls "gcc -E $*". After a
bit of thinking I must say that this is a cleaner solution than linking to
the real cpp. Now I do not need to update this link anymore after
upgrading gcc. 

ron

-- 
\ Ronald Wahl --- rwa@informatik.tu-chemnitz.de   \
 \ WWW: http://www.tu-chemnitz.de/~row             \
  \ Talk: rwa@goliath.csn.tu-chemnitz.de            \
   \ PGP key available by finger to my email address \


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: cpp doesn't define symbol i386
  1997-10-13 18:42     ` Ronald.Wahl
@ 1997-10-14  1:23       ` Ronald.Wahl
  1997-10-14 11:01         ` Jim Wilson
  1997-10-14 12:48         ` Tkil the Morose
  0 siblings, 2 replies; 10+ messages in thread
From: Ronald.Wahl @ 1997-10-14  1:23 UTC (permalink / raw)
  To: Jim Wilson; +Cc: law, egcs

On Tue, 14 Oct 1997 Ronald.Wahl@Informatik.TU-Chemnitz.DE wrote:

> On Mon, 13 Oct 1997, Jim Wilson wrote:
> 
> > 	As far as I can tell i386 should still be defined.  Can you investigate
> > 	why it's not being defined?
> > 
> > i386 is defined only if you use `gcc -E'.  This person is complaining that
> > it is not defined if you use `cpp'.  I think the answer here is to tell people
> > that they can't rely on using `cpp' for preprocessing stuff that isn't C code,
> > but if they really want to use it, then they should use `gcc -E' (or maybe
> > even `gcc -E -traditional') instead of just `cpp'.
> 
> Hmm, now I replaced /lib/cpp by a script which calls "gcc -E $*". After a
> bit of thinking I must say that this is a cleaner solution than linking to
> the real cpp. Now I do not need to update this link anymore after
> upgrading gcc. 

It's not as easy as I thought...

"gcc -E" is not equivalent to cpp because cpp read from stdin by default
and "gcc -E" needs the parameter "-" to force reading from stdin. But
hardcoding "-" in a shellscript will not be a solution due to cases where
cpp is called with an inputfile. Is it possible to change the behavior of
"gcc -E" so that it reads from stdin by default? 

ron

-- 
\ Ronald Wahl --- rwa@informatik.tu-chemnitz.de   \
 \ WWW: http://www.tu-chemnitz.de/~row             \
  \ Talk: rwa@goliath.csn.tu-chemnitz.de            \
   \ PGP key available by finger to my email address \


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: cpp doesn't define symbol i386
  1997-10-14  1:23       ` Ronald.Wahl
@ 1997-10-14 11:01         ` Jim Wilson
  1997-10-14 12:48         ` Tkil the Morose
  1 sibling, 0 replies; 10+ messages in thread
From: Jim Wilson @ 1997-10-14 11:01 UTC (permalink / raw)
  To: Ronald.Wahl; +Cc: law, egcs

	Is it possible to change the behavior of
	"gcc -E" so that it reads from stdin by default? 

I'd rather not.  The behaviour of gcc -E is well established.

	"gcc -E" is not equivalent to cpp because cpp read from stdin by default
	and "gcc -E" needs the parameter "-" to force reading from stdin. But
	hardcoding "-" in a shellscript will not be a solution due to cases where
	cpp is called with an inputfile. 

Perhaps you can write a shell script that checks for an input file and passes
the extra "-" if there isn't one?

Or maybe what we really need is a /lib/cpp drop in replacement program so
that people will stop trying to use gcc's cpp program for this purpose.
It shouldn't be too hard, we could just call gcc with a few options,
-E, -traditional, and maybe even a -x option, along with the '-' option if
there is no input file.

Jim

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: cpp doesn't define symbol i386
  1997-10-14  1:23       ` Ronald.Wahl
  1997-10-14 11:01         ` Jim Wilson
@ 1997-10-14 12:48         ` Tkil the Morose
  1997-10-14 14:01           ` Ronald.Wahl
  1997-10-15  6:09           ` Jesse Thilo
  1 sibling, 2 replies; 10+ messages in thread
From: Tkil the Morose @ 1997-10-14 12:48 UTC (permalink / raw)
  To: Ronald.Wahl; +Cc: egcs

Ronald.Wahl@informatik.tu-chemnitz.de writes:

[regarding using a small shell script wrapper as 'cpp':]
 
> "gcc -E" is not equivalent to cpp because cpp read from stdin by default
> and "gcc -E" needs the parameter "-" to force reading from stdin. But
> hardcoding "-" in a shellscript will not be a solution due to cases where
> cpp is called with an inputfile. Is it possible to change the behavior of
> "gcc -E" so that it reads from stdin by default? 

Ronald:

does this do the trick?

   #!/bin/bash
   gcc -E ${*:-'-'}

t.
-- 
Tkil * <URL: http://scrye.com/~tkil > * hopelessly hopeless romantic.
  "So amplify this little one 	|   She hears as much as she can see
   She's a volume freak       	|   And what she sees, she can't believe."
        -- Catherine Wheel, _Happy Days_, "Judy Staring At The Sun"

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: cpp doesn't define symbol i386
  1997-10-14 12:48         ` Tkil the Morose
@ 1997-10-14 14:01           ` Ronald.Wahl
  1997-10-15  6:09           ` Jesse Thilo
  1 sibling, 0 replies; 10+ messages in thread
From: Ronald.Wahl @ 1997-10-14 14:01 UTC (permalink / raw)
  To: Tkil the Morose; +Cc: egcs

On 14 Oct 1997, Tkil the Morose wrote:

> 
> Ronald.Wahl@informatik.tu-chemnitz.de writes:
> 
> [regarding using a small shell script wrapper as 'cpp':]
>  
> > "gcc -E" is not equivalent to cpp because cpp read from stdin by default
> > and "gcc -E" needs the parameter "-" to force reading from stdin. But
> > hardcoding "-" in a shellscript will not be a solution due to cases where
> > cpp is called with an inputfile. Is it possible to change the behavior of
> > "gcc -E" so that it reads from stdin by default? 
> 
> Ronald:
> 
> does this do the trick?
> 
>    #!/bin/bash
>    gcc -E ${*:-'-'}

No, since if you call this script with -Dxxx it will not append "-". But
I have written a wrapper which seems to work. Here is the C code:

------------------ snip ---------------------------------------
#include <stdlib.h>
#include <unistd.h>

int isFile(char * arg)
{
	if ( arg[0] != 0 && ( ( arg[0] == '-' && arg[1] == 0 ) || arg[0] != '-' ) )
		return 1;
	return 0;
}

int main( int argc, char * argv[] )
{
	int     i, j, files;
	char ** cpp_argv = (char **) malloc( ( argc + 2 ) * sizeof( char * ) );

	j = 0;
	cpp_argv[j++] = "gcc";
	cpp_argv[j++] = "-E";
	
	/* if last parameter is not a file we have to add the parameter "-" to gcc */
	if ( argc > 1 ) {
		/*
		 *  copy commandline parameters
		 */
		for ( i = 1, files = 0; i < argc; i++ ) {
			if ( isFile( argv[i] ) )
				if ( ++files == 2 )
					/*
					 *  the second file is the outputfile
					 *  so we need to insert -o for gcc
					 */
					cpp_argv[j++] = "-o";
			cpp_argv[j++] = argv[i];
		}

		/*
		 *  if the last commandline parameter isn't a file
		 *  we have to add the parameter `-' to gcc
		 */
		if ( ! isFile( argv[argc - 1] ) )
			cpp_argv[j++] = "-";
	} else
		cpp_argv[j++] = "-";
	cpp_argv[j++] = NULL;

	execvp("gcc", cpp_argv);
	
	return 0;
}
------------------------- snip --------------------------------

ron

-- 
\ Ronald Wahl --- rwa@informatik.tu-chemnitz.de   \
 \ WWW: http://www.tu-chemnitz.de/~row             \
  \ Talk: rwa@goliath.csn.tu-chemnitz.de            \
   \ PGP key available by finger to my email address \



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: cpp doesn't define symbol i386
  1997-10-14 12:48         ` Tkil the Morose
  1997-10-14 14:01           ` Ronald.Wahl
@ 1997-10-15  6:09           ` Jesse Thilo
  1997-10-15 20:16             ` Ronald.Wahl
  1 sibling, 1 reply; 10+ messages in thread
From: Jesse Thilo @ 1997-10-15  6:09 UTC (permalink / raw)
  To: egcs

> [regarding using a small shell script wrapper as 'cpp':]
>  
> > "gcc -E" is not equivalent to cpp because cpp read from stdin by default
> > and "gcc -E" needs the parameter "-" to force reading from stdin. But
> > hardcoding "-" in a shellscript will not be a solution due to cases where
> > cpp is called with an inputfile. Is it possible to change the behavior of
> > "gcc -E" so that it reads from stdin by default? 
> 
> does this do the trick?
> 
>    #!/bin/bash
>    gcc -E ${*:-'-'}

Problem: what if there are command line options, like -I/foo/bar or
-Dfoo=bar?  Here's what I use:

#!/bin/sh
exec `gcc -print-prog-name=cpp` -traditional ${1+"$@"}

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: cpp doesn't define symbol i386
  1997-10-15  6:09           ` Jesse Thilo
@ 1997-10-15 20:16             ` Ronald.Wahl
  0 siblings, 0 replies; 10+ messages in thread
From: Ronald.Wahl @ 1997-10-15 20:16 UTC (permalink / raw)
  To: egcs

On Wed, 15 Oct 1997, Jesse Thilo wrote:

> > [regarding using a small shell script wrapper as 'cpp':]
> >  
> > > "gcc -E" is not equivalent to cpp because cpp read from stdin by default
> > > and "gcc -E" needs the parameter "-" to force reading from stdin. But
> > > hardcoding "-" in a shellscript will not be a solution due to cases where
> > > cpp is called with an inputfile. Is it possible to change the behavior of
> > > "gcc -E" so that it reads from stdin by default? 
> > 
> > does this do the trick?
> > 
> >    #!/bin/bash
> >    gcc -E ${*:-'-'}
> 
> Problem: what if there are command line options, like -I/foo/bar or
> -Dfoo=bar?  Here's what I use:
> 
> #!/bin/sh
> exec `gcc -print-prog-name=cpp` -traditional ${1+"$@"}

You call cpp directly which causes problems at least with X under linux
if you try to use xmkmf/imake to generate Makefiles from Imakefiles. cpp
dosn't predefine some symbols (i386, ...) anymore. Now imake can't
determine the correct architecture and will generate the wrong Makefile.
That's why we need to call "gcc -E". The wrapper I posted here will do the
job.

ron

-- 
\ Ronald Wahl --- rwa@informatik.tu-chemnitz.de   \
 \ WWW: http://www.tu-chemnitz.de/~row             \
  \ Talk: rwa@goliath.csn.tu-chemnitz.de            \
   \ PGP key available by finger to my email address \


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~1997-10-15 20:16 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-10-11 14:26 cpp doesn't define symbol i386 Ronald.Wahl
1997-10-13 11:12 ` Jeffrey A Law
1997-10-13 15:02   ` Jim Wilson
1997-10-13 18:42     ` Ronald.Wahl
1997-10-14  1:23       ` Ronald.Wahl
1997-10-14 11:01         ` Jim Wilson
1997-10-14 12:48         ` Tkil the Morose
1997-10-14 14:01           ` Ronald.Wahl
1997-10-15  6:09           ` Jesse Thilo
1997-10-15 20:16             ` Ronald.Wahl

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).