Results 1 to 6 of 6

Thread: using directive and size_t in loop for

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2006
    Location
    The Netherlands
    Posts
    300
    Thanks
    9
    Thanked 29 Times in 29 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: using directive and size_t in loop for

    Heh, I knew that statement was gonna come back and bite me in the a3.

    I'm designing a programming language now with (among other things) a single int-type, which is sized correctly at compile-time, by trying to find the actual limits in the code (or using a dynamic int if this is impossible). That might remove the need for such things.
    "The strength of a civilization is not measured by its ability to wage wars, but rather by its ability to prevent them." - Gene Roddenberry

  2. #2
    Join Date
    Jan 2006
    Posts
    976
    Thanks
    53
    Qt products
    Qt3
    Platforms
    Windows

    Default Re: using directive and size_t in loop for

    Hello,
    1. I meant some drawback much more important. So I guess there aren't
    2. I don't sure to understand: apart 32b or 64b, I wonder even if could be different compiling my code with different compiler (not only MS compiler).....Does Anyone have this warning? How do you solve it? (I mean, the most elegant way.....)
    3.(Finally) I read that in the .h it's better don't allocate memory: eg. if I have a class where inside a "vector<double>* ivec" (Beyond if is better take the vector on the stack instead on the heap....); it's better call the "ivec = new vector<int>(10000);" not in a inlined constructor but keep it out of the .h, but in the implementation (.cpp). But is there any performance/compiling reasons (maybe something will change in the .obj file?) ?

    thanks.
    Regards

  3. #3
    Join Date
    Mar 2006
    Location
    The Netherlands
    Posts
    300
    Thanks
    9
    Thanked 29 Times in 29 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: using directive and size_t in loop for

    1. No, there aren't.
    2. I get a "comparing signed with unsigned integer" warning when I use int. The solution is to use unsigned int. If that doesn't work for you, it's MS specific.
    3. There are no performance reasons for putting the constructor code anywhere specific, as far as I know. It's just that if you want to change the 10000 to 20000, you will have to recompile every file that includes your header. Whereas if you put it in your .cc/.cpp file, you'll only have to recompile that one.
    "The strength of a civilization is not measured by its ability to wage wars, but rather by its ability to prevent them." - Gene Roddenberry

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.