Subject: Compilation warnings with gcc-3.0

From: André Dahlqvist <[email-masked]>
Date: Wed, 20 Jun 2001 01:24:15 +0200

Hi developers,

I just compiled the current CVS version of FVWM with the newly released
gcc 3.0. The compile finished successfully, but I got these warning during
the build:

FvwmCpp.o: In function `cpp_defs':
/home/andre/devel/cvs/fvwm-build/modules/FvwmCpp/FvwmCpp.c:255: the use of `mktemp' is dangerous, better use `mkstemp'
readconfig.c:1094:3: warning: pasting "." and "buttonState" does not give a valid preprocessing token
readconfig.c:1094:3: warning: pasting "." and "buttonState" does not give a valid preprocessing token
readconfig.c:1101:3: warning: pasting "." and "foreColorName" does not give a valid preprocessing token
readconfig.c:1101:3: warning: pasting "." and "foreColorName" does not give a valid preprocessing token
readconfig.c:1111:3: warning: pasting "." and "backColorName" does not give a valid preprocessing token
readconfig.c:1111:3: warning: pasting "." and "backColorName" does not give a valid preprocessing token
readconfig.c:1282:11: warning: pasting "." and "colorsets" does not give a valid preprocessing token
readconfig.c:1282:11: warning: pasting "." and "colorsets" does not give a valid preprocessing token
readconfig.c:1295:11: warning: pasting "." and "backColorName" does not give a valid preprocessing token
readconfig.c:1295:11: warning: pasting "." and "backColorName" does not give a valid preprocessing token
readconfig.c:1306:9: warning: pasting "." and "button_geometry_str" does not give a valid preprocessing token
readconfig.c:1306:9: warning: pasting "." and "button_geometry_str" does not give a valid preprocessing token
readconfig.c:1361:9: warning: pasting "." and "draw_icons" does not give a valid preprocessing token
readconfig.c:1361:9: warning: pasting "." and "draw_icons" does not give a valid preprocessing token
readconfig.c:1385:9: warning: pasting "." and "followFocus" does not give a valid preprocessing token
readconfig.c:1385:9: warning: pasting "." and "followFocus" does not give a valid preprocessing token
readconfig.c:1396:9: warning: pasting "." and "fontname" does not give a valid preprocessing token
readconfig.c:1396:9: warning: pasting "." and "fontname" does not give a valid preprocessing token
readconfig.c:1408:9: warning: pasting "." and "foreColorName" does not give a valid preprocessing token
readconfig.c:1408:9: warning: pasting "." and "foreColorName" does not give a valid preprocessing token
readconfig.c:1428:9: warning: pasting "." and "formatstring" does not give a valid preprocessing token
readconfig.c:1428:9: warning: pasting "." and "formatstring" does not give a valid preprocessing token
readconfig.c:1431:9: warning: pasting "." and "format_depend" does not give a valid preprocessing token
readconfig.c:1431:9: warning: pasting "." and "format_depend" does not give a valid preprocessing token
readconfig.c:1452:9: warning: pasting "." and "iconname" does not give a valid preprocessing token
readconfig.c:1452:9: warning: pasting "." and "iconname" does not give a valid preprocessing token
readconfig.c:1463:9: warning: pasting "." and "geometry_str" does not give a valid preprocessing token
readconfig.c:1463:9: warning: pasting "." and "geometry_str" does not give a valid preprocessing token
readconfig.c:1489:9: warning: pasting "." and "res" does not give a valid preprocessing token
readconfig.c:1489:9: warning: pasting "." and "res" does not give a valid preprocessing token
readconfig.c:1510:9: warning: pasting "." and "rev" does not give a valid preprocessing token
readconfig.c:1510:9: warning: pasting "." and "rev" does not give a valid preprocessing token
readconfig.c:1535:9: warning: pasting "." and "shaped" does not give a valid preprocessing token
readconfig.c:1535:9: warning: pasting "." and "shaped" does not give a valid preprocessing token
readconfig.c:1602:9: warning: pasting "." and "sort" does not give a valid preprocessing token
readconfig.c:1602:9: warning: pasting "." and "sort" does not give a valid preprocessing token
readconfig.c:1618:9: warning: pasting "." and "AnimCommand" does not give a valid preprocessing token
readconfig.c:1618:9: warning: pasting "." and "AnimCommand" does not give a valid preprocessing token
readconfig.c:1636:9: warning: pasting "." and "titlename" does not give a valid preprocessing token
readconfig.c:1636:9: warning: pasting "." and "titlename" does not give a valid preprocessing token
readconfig.c:1669:9: warning: pasting "." and "colorsets" does not give a valid preprocessing token
readconfig.c:1669:9: warning: pasting "." and "colorsets" does not give a valid preprocessing token
readconfig.c:1683:9: warning: pasting "." and "colorsets" does not give a valid preprocessing token
readconfig.c:1683:9: warning: pasting "." and "colorsets" does not give a valid preprocessing token
readconfig.c:1697:9: warning: pasting "." and "colorsets" does not give a valid preprocessing token
readconfig.c:1697:9: warning: pasting "." and "colorsets" does not give a valid preprocessing token
readconfig.c:1711:9: warning: pasting "." and "colorsets" does not give a valid preprocessing token
readconfig.c:1711:9: warning: pasting "." and "colorsets" does not give a valid preprocessing token
readconfig.c:1725:9: warning: pasting "." and "colorsets" does not give a valid preprocessing token
readconfig.c:1725:9: warning: pasting "." and "colorsets" does not give a valid preprocessing token
readconfig.c:1739:9: warning: pasting "." and "colorsets" does not give a valid preprocessing token
readconfig.c:1739:9: warning: pasting "." and "colorsets" does not give a valid preprocessing token
readconfig.c:1761:9: warning: pasting "." and "usewinlist" does not give a valid preprocessing token
readconfig.c:1761:9: warning: pasting "." and "usewinlist" does not give a valid preprocessing token
xmanager.c:367:9: warning: pasting "->" and "iconname" does not give a valid preprocessing token
xmanager.c:371:9: warning: pasting "->" and "titlename" does not give a valid preprocessing token
xmanager.c:375:9: warning: pasting "->" and "resname" does not give a valid preprocessing token
xmanager.c:379:9: warning: pasting "->" and "classname" does not give a valid preprocessing token
FvwmM4.o: In function `m4_defs':
/home/andre/devel/cvs/fvwm-build/modules/FvwmM4/FvwmM4.c:270: the use of `mktemp' is dangerous, better use `mkstemp'
-- 

André Dahlqvist <[email-masked]>
--
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-masked].
To report problems, send mail to [email-masked]

---

From: Dominik Vogt <[email-masked]>
Date: Fri, 22 Jun 2001 08:54:52 +0200

> /home/andre/devel/cvs/fvwm-build/modules/FvwmCpp/FvwmCpp.c:255: the use of `mktemp' is dangerous, better use `mkstemp'

We know about the mktemp warnings already but don't know what to
do about it.

> ...

This is the code:

  #define SET_MANAGER(manager,field,value)                           \
     do {                                                            \
       ...
	   globals.managers[id].##field = value;                     \
       ...
       }                                                             \
     } while (0)
  
  ...
   
  SET_MANAGER (manager, buttonState[context], state);

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.

Bye

Dominik ^_^  ^_^

--
Dominik Vogt, [email-masked]
Reply-To: [email-masked]

---

From: Lorenz Minder <[email-masked]>
Date: Sat, 23 Jun 2001 02:08:00 +0200

> 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-masked].
To report problems, send mail to [email-masked]

---

From: Mikhael Goikhman <[email-masked]>
Date: Sat, 23 Jun 2001 00:19:14 +0000

> +       globals.managers[id].field = value;                         \

I am not a preprocessor profi, but the fact that the original ## existed
suggests that not all preprocessors recognize "field" as parameter here.
I would replace ## with a space to be sure.

Regards,
Mikhael.