I got a nice 27 warnings from my compiler (VS 2003) when I included the following header file <sphelper.h> (This is for the speech 5.1 api). I have included it if anyone wants to have a look at it.
Now my program compiles fine, but I would like to get rid of these warnings. Now it says:
sphelper.h(334) : warning C4267: 'initializing' : conversion from 'size_t' to 'ULONG', possible loss of data.
I have looked within the stdlib.h file, and size_t is declared as an unsigned int. Now shall i change every definition of size_t within every header file to ULONG, or should I start changing this header file? What is best to do?
Warnings aren't always important. In this case, I don't think there's any need for concern. The issue I believe is that an 'int' can either be 16-bit or 32-bit, depending on your processor. Basically every processer you can find these days is 32-bit. A ULONG is always 32-bits. Thus, you get a warning because theoretically your code may produce undefined behavior on some systems. However, it's not something you should worry about. Just ignore the warnings.
:-) Ok, but I just like a nice clean build with no errors and no warnings.... Doesn't every programmer? Ok, thanks for the help.
> The issue I believe is that an 'int' can either be 16-bit or 32-bit,
Don't forget 64 bit.
The warning is telling you that if int were to become 64 bit, then you may have loss of data, even if that is currently impossible in your current implementation.
> I got a nice 27 warnings from my compiler (VS 2003)
Send a bug report to MS to ask them to fix the implementation.
If you can't include any header file at the maximum warning level without it generating internal warnings, then it is broken.