* Strange gcc-3.0.1 preprocessor
@ 2001-10-14 7:46 Nick Kurshev
2001-10-14 8:12 ` Neil Booth
0 siblings, 1 reply; 7+ messages in thread
From: Nick Kurshev @ 2001-10-14 7:46 UTC (permalink / raw)
To: gcc
Hello!
I've tried to compile my project with new gcc-3.0.1 and got strange error. :(
command:
gcc -D__MACHINE__=ia32 ...
source code:
#define _INLINES <biewlib/sysdep/##__MACHINE__/_inlines.h>
#define __CONFIG <biewlib/sysdep/##__MACHINE__/__config.h>
#include __CONFIG
#include _INLINES
stderr output:
In file included from biewlib/biewlib.h:25,
from biewlib/bbio.h:21,
from biewlib/bbio.c:26:
biewlib/sysdep/_sys_dep.h:30:14: warning: pasting "/" and "__MACHINE__" does not give a valid preprocessing token
biewlib/sysdep/_sys_dep.h:30:22: biewlib/sysdep/__MACHINE__/__config.h: No such file or directory
biewlib/sysdep/_sys_dep.h:31:14: warning: pasting "/" and "__MACHINE__" does not give a valid preprocessing token
biewlib/sysdep/_sys_dep.h:31:22: biewlib/sysdep/__MACHINE__/_inlines.h: No such file or directory
Only one question: Is it a bug or is it a new feature of gcc-3.0.1?
Any previouse versions of gcc since 2.7.2.1 upto 2.95.3 handle this code correctly.
Best regards! Nick
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Strange gcc-3.0.1 preprocessor
2001-10-14 7:46 Strange gcc-3.0.1 preprocessor Nick Kurshev
@ 2001-10-14 8:12 ` Neil Booth
2001-10-14 10:45 ` Nick Kurshev
0 siblings, 1 reply; 7+ messages in thread
From: Neil Booth @ 2001-10-14 8:12 UTC (permalink / raw)
To: Nick Kurshev; +Cc: gcc
Nick Kurshev wrote:-
> In file included from biewlib/biewlib.h:25,
> from biewlib/bbio.h:21,
> from biewlib/bbio.c:26:
> biewlib/sysdep/_sys_dep.h:30:14: warning: pasting "/" and "__MACHINE__" does not give a valid preprocessing token
> biewlib/sysdep/_sys_dep.h:30:22: biewlib/sysdep/__MACHINE__/__config.h: No such file or directory
> biewlib/sysdep/_sys_dep.h:31:14: warning: pasting "/" and "__MACHINE__" does not give a valid preprocessing token
> biewlib/sysdep/_sys_dep.h:31:22: biewlib/sysdep/__MACHINE__/_inlines.h: No such file or directory
>
> Only one question: Is it a bug or is it a new feature of gcc-3.0.1?
The warning tells you the problem. Do you know what ## does?
> Any previouse versions of gcc since 2.7.2.1 upto 2.95.3 handle this
> code correctly.
They are incorrect; from the code it would appear they used to expand
__MACHINE__. That macro should not be expanded, since it is being
operated on by ##.
I suspect you can get the result you want by losing the ##.
Neil.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Strange gcc-3.0.1 preprocessor
2001-10-14 8:12 ` Neil Booth
@ 2001-10-14 10:45 ` Nick Kurshev
2001-10-14 10:59 ` Neil Booth
0 siblings, 1 reply; 7+ messages in thread
From: Nick Kurshev @ 2001-10-14 10:45 UTC (permalink / raw)
To: Neil Booth; +Cc: gcc
Hello, Neil!
On Sun, 14 Oct 2001 16:12:22 +0100, you wrote:
> Nick Kurshev wrote:-
>
> > In file included from biewlib/biewlib.h:25,
> > from biewlib/bbio.h:21,
> > from biewlib/bbio.c:26:
> > biewlib/sysdep/_sys_dep.h:30:14: warning: pasting "/" and "__MACHINE__" does not give a valid preprocessing token
> > biewlib/sysdep/_sys_dep.h:30:22: biewlib/sysdep/__MACHINE__/__config.h: No such file or directory
> > biewlib/sysdep/_sys_dep.h:31:14: warning: pasting "/" and "__MACHINE__" does not give a valid preprocessing token
> > biewlib/sysdep/_sys_dep.h:31:22: biewlib/sysdep/__MACHINE__/_inlines.h: No such file or directory
> >
> > Only one question: Is it a bug or is it a new feature of gcc-3.0.1?
>
> The warning tells you the problem. Do you know what ## does?
>
It was only way to build such trick. Else how you will notice compiler to build preprocessor string
without space characters?
Well, the same code with space characters around __MACHINE__:
source:
#define _INLINES <biewlib/sysdep/ __MACHINE__ /_inlines.h>
#define __CONFIG <biewlib/sysdep/ __MACHINE__ /__config.h>
#include __CONFIG
#include _INLINES
output:
biewlib/sysdep/_sys_dep.h:30:22: biewlib/sysdep/ ia32 /__config.h: No such file or directory
biewlib/sysdep/_sys_dep.h:31:22: biewlib/sysdep/ ia32 /_inlines.h: No such file or directory
> > Any previouse versions of gcc since 2.7.2.1 upto 2.95.3 handle this
> > code correctly.
>
> They are incorrect; from the code it would appear they used to expand
> __MACHINE__. That macro should not be expanded, since it is being
> operated on by ##.
>
> I suspect you can get the result you want by losing the ##.
Well, other trick:
command:
gcc -D__MACHINE__='"ia32"'
source:
#define _INLINES <"biewlib/sysdep/"__MACHINE__"/_inlines.h">
#define __CONFIG <"biewlib/sysdep/"__MACHINE__"/__config.h">
#include __CONFIG
#include _INLINES
output:
biewlib/sysdep/_sys_dep.h:30:22: "biewlib/sysdep/"ia32"/__config.h": No such file or directory
biewlib/sysdep/_sys_dep.h:31:22: "biewlib/sysdep/"ia32"/_inlines.h": No such file or directory
So I have no solutions with new gcc-3.x branch for now.
Need some other trick.
From other point - it's PREPROCESSOR but not C compiler which can concatenate several strings to one.
>
> Neil.
>
>
Best regards! Nick
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Strange gcc-3.0.1 preprocessor
2001-10-14 10:45 ` Nick Kurshev
@ 2001-10-14 10:59 ` Neil Booth
2001-10-14 11:06 ` Nick Kurshev
0 siblings, 1 reply; 7+ messages in thread
From: Neil Booth @ 2001-10-14 10:59 UTC (permalink / raw)
To: Nick Kurshev; +Cc: gcc
Nick Kurshev wrote:-
> It was only way to build such trick. Else how you will notice
> compiler to build preprocessor string without space characters?
Like I told you.
> Well, the same code with space characters around __MACHINE__:
> source:
> #define _INLINES <biewlib/sysdep/ __MACHINE__ /_inlines.h>
> #define __CONFIG <biewlib/sysdep/ __MACHINE__ /__config.h>
> #include __CONFIG
> #include _INLINES
Why have you added spaces? Of course it will now break:
> output:
> biewlib/sysdep/_sys_dep.h:30:22: biewlib/sysdep/ ia32 /__config.h: No such file or directory
> biewlib/sysdep/_sys_dep.h:31:22: biewlib/sysdep/ ia32 /_inlines.h: No such file or directory
The following works for me:
#define STDIO stdio
#define STDIO_H </usr/include/STDIO.h>
#include STDIO_H
Note that the preprocessor does not do string literal concatenation in
header names.
Neil.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Strange gcc-3.0.1 preprocessor
2001-10-14 10:59 ` Neil Booth
@ 2001-10-14 11:06 ` Nick Kurshev
2001-10-14 11:09 ` Neil Booth
0 siblings, 1 reply; 7+ messages in thread
From: Nick Kurshev @ 2001-10-14 11:06 UTC (permalink / raw)
To: Neil Booth; +Cc: gcc
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1567 bytes --]
Hello, Neil!
On Sun, 14 Oct 2001 18:59:34 +0100, you wrote:
> Nick Kurshev wrote:-
>
> > It was only way to build such trick. Else how you will notice
> > compiler to build preprocessor string without space characters?
>
> Like I told you.
>
> > Well, the same code with space characters around __MACHINE__:
> > source:
> > #define _INLINES <biewlib/sysdep/ __MACHINE__ /_inlines.h>
> > #define __CONFIG <biewlib/sysdep/ __MACHINE__ /__config.h>
> > #include __CONFIG
> > #include _INLINES
>
> Why have you added spaces? Of course it will now break:
>
> > output:
> > biewlib/sysdep/_sys_dep.h:30:22: biewlib/sysdep/ ia32 /__config.h: No such file or directory
> > biewlib/sysdep/_sys_dep.h:31:22: biewlib/sysdep/ ia32 /_inlines.h: No such file or directory
>
> The following works for me:
>
> #define STDIO stdio
> #define STDIO_H </usr/include/STDIO.h>
> #include STDIO_H
>
> Note that the preprocessor does not do string literal concatenation in
> header names.
>
> Neil.
>
But for me - no.
#undef __MACHINE__
#define __MACHINE__ ia32
#define _INLINES <biewlib/sysdep/__MACHINE__/_inlines.h>
#define __CONFIG <biewlib/sysdep/__MACHINE__/__config.h>
#include __CONFIG
#include _INLINES
In file included from biewlib/biewlib.c:24:
biewlib/sysdep/__config.h:27:14: warning: pasting "/" and "__MACHINE__" does not give a valid preprocessing token
biewlib/sysdep/__config.h:27:22: biewlib/sysdep/__MACHINE__/__config.h: No such file or directory
make: *** [biewlib/biewlib.o] ïÃÃÃÃà 1
Best regards! Nick
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Strange gcc-3.0.1 preprocessor
2001-10-14 11:06 ` Nick Kurshev
@ 2001-10-14 11:09 ` Neil Booth
2001-10-15 10:59 ` Nick Kurshev
0 siblings, 1 reply; 7+ messages in thread
From: Neil Booth @ 2001-10-14 11:09 UTC (permalink / raw)
To: Nick Kurshev; +Cc: gcc
Nick Kurshev wrote:-
> But for me - no.
I don't believe you.
> #undef __MACHINE__
> #define __MACHINE__ ia32
> #define _INLINES <biewlib/sysdep/__MACHINE__/_inlines.h>
> #define __CONFIG <biewlib/sysdep/__MACHINE__/__config.h>
> #include __CONFIG
> #include _INLINES
>
> In file included from biewlib/biewlib.c:24:
> biewlib/sysdep/__config.h:27:14: warning: pasting "/" and "__MACHINE__" does not give a valid preprocessing token
> biewlib/sysdep/__config.h:27:22: biewlib/sysdep/__MACHINE__/__config.h: No such file or directory
> make: *** [biewlib/biewlib.o] 1
Why is it complaining about pasting? I don't think the code you quote
above is not the code you are using; the code you are using still has
the ## that I asked you to remove.
Neil.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Strange gcc-3.0.1 preprocessor
2001-10-14 11:09 ` Neil Booth
@ 2001-10-15 10:59 ` Nick Kurshev
0 siblings, 0 replies; 7+ messages in thread
From: Nick Kurshev @ 2001-10-15 10:59 UTC (permalink / raw)
To: Neil Booth; +Cc: gcc
Hello, Neil!
On Sun, 14 Oct 2001 19:09:04 +0100, you wrote:
> Nick Kurshev wrote:-
>
> > But for me - no.
>
> I don't believe you.
>
> > #undef __MACHINE__
> > #define __MACHINE__ ia32
> > #define _INLINES <biewlib/sysdep/__MACHINE__/_inlines.h>
> > #define __CONFIG <biewlib/sysdep/__MACHINE__/__config.h>
> > #include __CONFIG
> > #include _INLINES
> >
> > In file included from biewlib/biewlib.c:24:
> > biewlib/sysdep/__config.h:27:14: warning: pasting "/" and "__MACHINE__" does not give a valid preprocessing token
> > biewlib/sysdep/__config.h:27:22: biewlib/sysdep/__MACHINE__/__config.h: No such file or directory
> > make: *** [biewlib/biewlib.o] 1
>
> Why is it complaining about pasting? I don't think the code you quote
> above is not the code you are using; the code you are using still has
> the ## that I asked you to remove.
>
Yes! You are perfectly right.
I cleaned not all such places.
Now it works. Thanks!
> Neil.
>
Best regards! Nick
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2001-10-15 10:59 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-10-14 7:46 Strange gcc-3.0.1 preprocessor Nick Kurshev
2001-10-14 8:12 ` Neil Booth
2001-10-14 10:45 ` Nick Kurshev
2001-10-14 10:59 ` Neil Booth
2001-10-14 11:06 ` Nick Kurshev
2001-10-14 11:09 ` Neil Booth
2001-10-15 10:59 ` Nick Kurshev
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).