Is this standards compliant?

From: Kenny McCormack (gazelle_at_yin.interaccess.com)
Date: 12/30/04


Date: Thu, 30 Dec 2004 18:44:22 GMT

Aka, "How to make this warning go away?"

I have some code that contains:

#define FOO 2123456789L

I.e., a number that is greater than the limit for a signed 32 bit int.

I cannot use the above in a statement w/o compiler (gcc 2.95) issuing
a warning that says: decimal constant so large it must be unsigned.

For example:

        unsigned int baz = FOO;

Should be OK, right?

Notes:
        1) This is on a machine where ints and longs are both 32 bits.
        2) I get same results with "long" instead of "int" (in the above
           declaration).

Also, I tried:

#define FOO 2000000000L+123456789L;

And I get a different error (error this time) saying integer overflow...

I assume somewhere in the standard it says that compiletime math has to
work up to some level, right?



Relevant Pages

  • Re: Initialising Variables
    ... int func; ... int foo; ... printf; ... the file contaiing the definition of func, and the warning would go ...
    (comp.lang.c)
  • Re: How can I prevent require duplicate files
    ... even with warning level set to 2 ... require 'thedef' ... % cat thedef.rb ... require 'foo' ...
    (comp.lang.ruby)
  • Weird gcc behaviour with function pointer types
    ... void g{ ... void (struct foo *); ... blarg.c:6: warning: assignment from incompatible pointer type ... This looks like a bug in gcc to me -- what do people ...
    (comp.lang.python)
  • Re: setq givs a warning i SBCL, Not CLISP
    ... If i do the same on CLISP i get no warning ... If you do by accident (setq x ...) you don't want x to be defined ... foo has a function as its value, ... names of global variables, just as a visual clue, so you might want ...
    (comp.lang.lisp)
  • Re: Scoping Question
    ... * (setf foo 3) ... Warning: This variable is undefined: ... WARN is an external symbol in the KEYWORD package. ... NIL -- Never declare the variable, ...
    (comp.lang.lisp)