Yet another enum question

See the following enum:

1
2
3
4
5
6
7
typedef enum _StdTaskDialogIcons : short int
{
	TDIconWarning = -1,
	TDIconError = -2,
	TDIconInformation = -3,
	TDIconShield = -4
} StdTaskDialogIcons;


In Visual C++ 2008 Pro, I get one warning per value, and the question is why??

2>taskdialog.h(69) : warning C4341: 'TDIconWarning' : signed value is out of range for enum constant
2>taskdialog.h(70) : warning C4341: 'TDIconError' : signed value is out of range for enum constant
2>taskdialog.h(71) : warning C4341: 'TDIconInformation' : signed value is out of range for enum constant
2>taskdialog.h(73) : warning C4341: 'TDIconShield' : signed value is out of range for enum constant


I don't see how -1, -2, -3 and -4 are outside the range of a short int. FYI, the warning also appears when the enum is based on int.

And one more FYI: The enum seems to work OK. I use it to specify the icon I want in a given Task Dialog (I have used TDIconError so far only).
A compiler bug, maybe? Looks fine to me.
I'm not convinced that that is a legal standard C++ declaration.
Last edited on
closed account (zb0S216C)
The compiler just doesn't like the fact that you're using signed numeric values instead of unsigned. However, a enumerated list that contains signed numeric values is still valid, but not as common. Enumerated lists are generally unsigned.

Wazzak
I see. Well, I'll post @ the MSDN forums to see if I get another light on this. If not, I'll post @ Microsoft Connect and report the bug.

Thanks.
Topic archived. No new replies allowed.