Windows 7 Installation

by Codewiz51 7. October 2009 20:40

I broke down and installed Windows 7 Ultimate tonight from my MSDN subscription downloads.  It's running on an Acer Aspire 5601LWMI laptop. Dual core 1.7 GHz processor, 1 GB RAM and 100 GB hard drive.  The installation experience was pleasant.  I had to search far and wide for Acer's TI flash driver for Vista, but otherwise, no irritants to speak of.


Tags: , ,


Upgraded BlogEngine.Net and ScrewTurn wiki

by Codewiz51 13. June 2009 14:29

I upgraded BlogEngine.Net to version 1.5 today.  There are some new features and widgets available.  The upgrade went very smoothly. I hope everyone likes the new theme.  I think it's easy on the eyes.

I managed to upgrade my wiki to version 2.0 also.  There is a new code colorizer that I am trying out.  I am not a fan of the colorizers because they make selecting and copying code from the web page a lot more difficult for the reader.  The color information has to be stripped out of the text.


Tags: , ,


Back to hobbyist programming...

by Codewiz51 2. February 2009 19:56

Finally, I can get back to the projects I love. I managed to complete the conversion of some software to work with Vista. The install package required quite a bit of modifcation as well. (UAC is definitely an abomination. There has to be a better way to implement it.)

There's a new WinROTT release 10.  I haven't made any progress converting to modern DirectX code. I am still trying to decipher the documentation and the scheme WinROTT uses to display graphics. To be honest, I am somewhat bewildered by all that is going on with DirectX. Maybe I'll start to click with it soon.

Tags: , ,


More On Mixing Signed and Unsigned Types in C++

by Codewiz51 9. January 2009 21:50

I decided to experiment a little more with signed and unsigned types. I found what seemed to me to be descrepancies in how Visual C++ 9.0 handles int, short and char types.

Here's the code I was working with. Rather than show output, I've added comments to illustrate the problem and descrepancies.

int _tmain(int argc, _TCHAR* argv[])
    unsigned int ui = 0x80000000;
    int si = 0x80000000;

    unsigned short us = 0x8000;

    // Generates warning C4309: 'initializing' : truncation of constant value

    short ss = 0x8000;

    unsigned char uc = 0x80;

    // Generates warning C4309: 'initializing' : truncation of constant value

    char sc = 0x80;

    // As you can see from the comments, VC 9 does not handle
    // int, short and char in a consistent manner when
    // working with signed and unsigned types.

    // Generates warning C4018: '<' : signed/unsigned mismatch

    bool ci = si < ui; // = false! Surprising but expected
                             // VC 9 must be casting si to unsigned
                             // before performing the comparison
    bool cs = ss < us; // = true
    bool cc = sc < uc; // = true
    ci = si == ui;    // true! Again wow, how'd that happen?
    cs = us == ss;    // false
    cc = uc == sc;    // false

    // Generates warning C4018: '<' : signed/unsigned mismatch
    ci = ui > si;    // false!
    cs = us > ss;    // true
    cc = uc > sc;    // true

    return 0;

The moral of the story is: understand the code you are writing. Boundary conditions can be particularly problematic when dealing with signed and unsigned types. If you don't truly understand the code, then take some time and experiment. Do not assume the compiler will handle a short and an int in the same manner. (In this case, the descrepancies appear to occur because the compiler casts the short and char types to 32 bit int before performing the comparison.)

In my case, I am porting an old game with lots of char and short logical operations. I want to change most of the types to int for the modernized code. However, you can see this might lead to unexpected results when logical operations are performed. My solution is to define all variables used as flags or bit flags as unsigned types.

Here's a quick reference for what I've run into: FAQs 3.18 and 3.19 - look under

Tags: ,


An Interesting Warning in C and C++

by Codewiz51 8. January 2009 18:47

While working on WinROTT, I have come across a couple of warnings that may actually be serious bugs. One warning is C4309: 'initializing' : truncation of constant value.

This appears to be innocuous. But maybe it's not.

The following statement generates a C4309 warning:

signed char tx = 0x80;

The value of tx is -128 after this declaration and initalization occurs.

Let's assume this is followed by:

// value of tp is 128
unsigned char tp = 0x80;
bool tc = tx == tp;

What's the value of tc? You might think it is true. But in reality, the comparison is -128 == 128 which is false.

This may be a contrived example. But consider when you are working in a normal c++ program, where the type may be hidden:

// header file (.h)
#define SF_BAT      0x80

// Forward only linked list
typedef struct  statestruct
    byte                rotate;
    short               shapenum;    // a shapenum of -1 means get from ob->temp1
    short               tictime;
    void                (*think) (void *);
    signed char      condition;     // GH originally signed char
                                             // Caused 0x80 to be assigned as -128
    struct statestruct    *next;    // Link to next struct
} statetype;

// implementation file (.cpp)
// C4309 warning occurs here
statetype s_batblast4 = {FALSE,BATBLAST4,3,T_Projectile,SF_BAT,&s_batblast1};

// Here's where the execution problem occurs
// This comparison will always return false
if (s_batblast4->condition == SF_BAT)
    // Do something here

The moral is, don't ignore warnings. They may not be harmless. In this case, changing condition to unsigned char is the correct fix.

Tags: , ,



This blog represents my personal hobby, observations and views. It does not represent the views of my employer, clients, especially my wife, children, in-laws, clergy, the dog, the cat or my daughter's horse. In fact, I am not even sure it represents my views when I take the time to reread postings.  So, take most of what I say with a grain of salt.

© Copyright 2008-2014