Dominik Vogt wrote:

> To me that seems as if the preprocessor is broken.  It issues a
> warning as if
> 
>   globals.managers[id].##field
> 
> was expanded to tow separate tokens:
> 
>   globals.managers[id] .buttonState[context]
>                      ^^^
> 
> and not to
> 
>   globals.managers[id].buttonState[context]
>                      ^^
> 
> And even if it split the token into two it would hardly ever
> matter since C does not care for the additional space.

I don't think that the preprocessor is broken. It's just that it is more
strict ANSI conformant than it used to be. (Correct me if I'm wrong, I
don't have an exact Standards description handy.)

What the warning is trying to say is that you're not allowed to use ##
with non-identifier-characters (period in this case); at any rate, it
won't insert a white space in such a case. And, it is just a warning; the
preprocessor does the Right Thing.

Consider the following:

==================================================================
lorinder$ cat > example
#define PERIODLEFT(x) .##x
#define CHARLEFT(x)     a##x

PERIODLEFT(foo)
#line 100
PERIODLEFT(;)
#line 1000
CHARLEFT(bar)
#line 10000
CHARLEFT(!)
lorinder$ /usr/bin/cpp --version
2.95.2
lorinder$ /usr/bin/cpp example 
# 1 "example"



.foo  
# 99 "example"

.;  
# 999 "example"

abar  
# 9999 "example"

a!  
lorinder$ /usr/local/bin/cpp --version
3.0
lorinder$ /usr/local/bin/cpp example  
example:4:1: warning: pasting "." and "foo" does not give a valid
preprocessing token
# 4 "example"
.foo
# 100 "example"
example:100:1: warning: pasting "." and ";" does not give a valid
preprocessing token
.;
# 1000 "example"
abar
# 10000 "example"
example:10000:1: warning: pasting "a" and "!" does not give a valid
preprocessing token
 a!
lorinder$ 
==================================================================

Hence, the fix is to simply remove the ##. This certainly can't break
anything since, as you pointed out, even if some preprocessors (wrongly)
insert a white space there, this won't cause any problems.

Thus, the following patch, which solves these problems, can be safely
applied.

Cheers,
--Lorenz


--- readconfig.c.orig   Thu Mar 29 00:36:11 2001
+++ readconfig.c        Sat Jun 23 01:54:12 2001
@@ -1047,11 +1047,11 @@
      int id = manager;                                             \
      if (id == -1) {                                               \
        for (id = 0; id < globals.num_managers; id++) {             \
-        globals.managers[id].##field = value;                     \
+        globals.managers[id].field = value;                       \
        }                                                           \
      }                                                             \
      else if (id < globals.num_managers) {                         \
-       globals.managers[id].##field = value;                       \
+       globals.managers[id].field = value;                         \
      }                                                             \
      else {                                                        \
        ConsoleMessage ("Internal error in SET_MANAGER: %d\n", id); \
--
Visit the official FVWM web page at <URL:http://www.fvwm.org/>.
To unsubscribe from the list, send "unsubscribe fvwm-workers" in the
body of a message to [EMAIL PROTECTED]
To report problems, send mail to [EMAIL PROTECTED]

Reply via email to