Results 1 to 5 of 5

Thread: which one is constant,sizeof(int) or sizeof(long)?

  1. #1
    Join Date
    Jan 2006
    Posts
    55
    Thanks
    13
    Qt products
    Qt3
    Platforms
    Unix/X11

    Question which one is constant,sizeof(int) or sizeof(long)?

    In order to transport a class through Tcp,I have to define constant length's variable in this class,between int and long,which one's size is constant on differernt CPU Type(32 and 64 bit)?
    thank you!

  2. #2
    Join Date
    Jan 2006
    Location
    Mountain View, CA
    Posts
    279
    Thanked 42 Times in 37 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: which one is constant,sizeof(int) or sizeof(long)?

    You shouldn't rely on either (all though in most cases you can).

    Instead use qint32, qint64, etc.
    Save yourself some pain. Learn C++ before learning Qt.

  3. #3
    Join Date
    Jan 2006
    Posts
    55
    Thanks
    13
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Re: which one is constant,sizeof(int) or sizeof(long)?

    but neither qint32 nor qint64 is defined in qt3.3.4.

  4. #4
    Join Date
    Jan 2006
    Location
    Mountain View, CA
    Posts
    279
    Thanked 42 Times in 37 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: which one is constant,sizeof(int) or sizeof(long)?

    Quote Originally Posted by coralbird
    but neither qint32 nor qint64 is defined in qt3.3.4.
    Q_INT32 and Q_INT64. They're all defined in qglobal.h
    Save yourself some pain. Learn C++ before learning Qt.

  5. #5
    Join Date
    Jan 2006
    Posts
    55
    Thanks
    13
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Re: which one is constant,sizeof(int) or sizeof(long)?

    thank Chicken Blood Machine !I have solved this problem as your guide.

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.