No more defaulting to int

Holy cow! Another one that’s probably going to be a pain in the neck (I am insistent on keeping this blog child-safe which is why I keep using names of the wrong parts of the body as you may have observed).

static bBusy = 0;
//error C4430: missing type specifier - int assumed.

That won’t compile either and the error message is pretty rotten – it assumes an int, but will still throw an error. Anyway this is another step towards standards compliance, so I won’t complain too much – but if any of you guys are using pre-VC++ 2005 compilers to write code today, better make sure you don’t use this sort of code – it’ll make your future coding life a lot easier.


4 thoughts on “No more defaulting to int

  1. I would hope that no one who learned C after about 1982 wrote code like that. 😉
    The “implicit int” was only needed before the days of void, so you could write
    a function like: “foobar(int)” that didn’t return anything. There was no void, so
    _some_ return type was needed, but the compiler assumed int if nothing was there.
    This shortcut spread to variable declarations as well.
    Implicit stuff should be confined to Perl, where it belongs.

  2. I have to agree. Any programmer working for me who wrote that code would have gotten
    the lecture about assuming WAY too much about what the compiler is doing for you.
    Under a lot of the more recent compilers (64 bit) you would have gotten an INT64 for
    your trouble, not an INT (maybe not what you were expecting to compare).

  3. For those with millions of lines of legacy code – even though it’s an error you
    can disable it completely with /wd4430. In fact many (most?) 4000 series errors you can
    disable with /wd

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s