Subject: Compiler warnings

From: [email-masked] (Paul D. Smith)
Date: 29 Jun 1999 14:32:10 -0400

While helping someone compile FVWM on SGI recently they were using the
bundled SGI C compiler, and they got _tons_ of warnings because of the
way we define bitfields in FVWM.  I've also heard of these types of
warnings with HP's C compiler.

Basically, we use this in many places:

  Bool  isThis:1;

The problem here is that Bool (an X type) is defined to be int, which is
a signed integer.  So there could [*] be a bit reserved for signedness.
But, we have only one bit.  Thus warnings.  Most compilers with DTRT
here, even as they spit out tons of warnings (it's a quality of
implementation issue :) but still it'd be nice to avoid them in the
first place.

Similarly, if we use something like:

  int   numItems:2;

we really can't be sure whether the valid values for this bitfield are
the expected 0-4, or {-2, -1, 0, 1}.

The latter is simple to fix, by using:

  unsigned int numItems:2;

The former can only be fixed by punting the X Bool type.  The question
is, should we just change these to straight "unsigned int" or do people
feel that creating a "uBool" type would be more appropriate?  I prefer
just using unsigned int, but I'm not losing sleep over it.

-----
[*] According to the C standard, whether or not an "int" bitfield is
    considered to have a sign bit or not is "implementation defined"; I
    hate that.  What use is it to have a standard if you're not going to
    define stuff like this?  "Implementation defined" is no better than
    not having a standard at all; you still can't use either feature
    portably. Argh.

-- 
-------------------------------------------------------------------------------
 Paul D. Smith <[email-masked]>         Network Management Development
 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist
-------------------------------------------------------------------------------
   These are my opinions---Nortel Networks takes no responsibility for them.
--
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: Matthias Clasen <[email-masked]>
Date: Tue, 29 Jun 1999 22:18:29 +0200

> just using unsigned int, but I'm not losing sleep over it.

unsigned int x :1 

is the correct way to do bitfields.

-- 
Matthias Clasen, 
Tel. 0761/203-5606
Email: [email-masked]
Mathematisches Institut, Albert-Ludwigs-Universitaet Freiburg
--
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: Tue, 29 Jun 1999 21:43:30 +0200

> just using unsigned int, but I'm not losing sleep over it.

In most other places we use

  unsigned foo:1;

For consistency it's better to always use it anyway. Let's simply make
the change.

Bye

Dominik ^_^

--
Dominik Vogt, [email-masked]
Reply-To: [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]