Work around MSVC false positive warning in price-tracking code
The MSVC warning assumes that any attempt to write - followed by an unsigned number is an attempt to create a negative number (which produces the wrong data type if you type, e.g., -2147483648). However, it's also warning when an explicit U is given, e.g. in -1UL, which is clearly not an attempt to express a negative value. Suppress the warning by rewriting the number in question as (0UL-1UL) with a binary rather than unary minus.
This commit is contained in:
@@ -41,10 +41,14 @@
|
||||
the second zero is oc_spare1 for padding between oc_tough and oc_dir */
|
||||
#define BITS(nmkn,mrg,uskn,ctnr,mgc,chrg,uniq,nwsh,big,tuf,dir,sub,mtrl) \
|
||||
nmkn,mrg,uskn,0,mgc,chrg,uniq,nwsh,big,tuf,0,dir,mtrl,sub /*cpp fodder*/
|
||||
/* note: 0UL-1UL is a method of expressing the largest possible
|
||||
unsigned long value whilst working around a false-positive warning
|
||||
in Microsoft Visual C (which assumes that a negative number was
|
||||
intended despite the explicit U suffix) */
|
||||
#define OBJECT(obj,bits,prp,sym,prob,dly,wt, \
|
||||
cost,sdam,ldam,oc1,oc2,nut,color,sn) \
|
||||
{ 0, 0, (char *) 0, bits, prp, sym, dly, color, prob, wt, \
|
||||
cost, sdam, ldam, oc1, oc2, nut, -1UL, 0, -1UL, 0 }
|
||||
cost, sdam, ldam, oc1, oc2, nut, (0UL-1UL), 0, (0UL-1UL), 0 }
|
||||
#define MARKER(tag,sn) /*empty*/
|
||||
|
||||
#elif defined(OBJECTS_ENUM)
|
||||
|
||||
Reference in New Issue
Block a user