Thread: size_t probs

  1. #1
    Registered User subdene's Avatar
    Join Date
    Jan 2002
    Posts
    367

    size_t probs

    Hi all,

    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?

    Thanks.
    Be a leader and not a follower.

  2. #2
    mustang benny bennyandthejets's Avatar
    Join Date
    Jul 2002
    Posts
    1,401
    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.
    [email protected]
    Microsoft Visual Studio .NET 2003 Enterprise Architect
    Windows XP Pro

    Code Tags
    Programming FAQ
    Tutorials

  3. #3
    Registered User subdene's Avatar
    Join Date
    Jan 2002
    Posts
    367
    :-) Ok, but I just like a nice clean build with no errors and no warnings.... Doesn't every programmer? Ok, thanks for the help.
    Be a leader and not a follower.

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    > 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.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. 2 simple C++ probs
    By alikoolg in forum C++ Programming
    Replies: 4
    Last Post: 03-18-2009, 09:02 PM
  2. Replies: 2
    Last Post: 11-04-2007, 12:55 PM
  3. WM_TIMER probs (FPS Calculations)
    By C+noob in forum C++ Programming
    Replies: 0
    Last Post: 10-02-2005, 02:39 AM
  4. Several Probs
    By gamer4life687 in forum C++ Programming
    Replies: 4
    Last Post: 12-25-2002, 07:40 PM
  5. magic sq probs
    By scuba22 in forum C++ Programming
    Replies: 2
    Last Post: 11-18-2002, 09:40 AM