What is the bit size of long on 64-bit Windows?

前端 未结 7 672
天涯浪人
天涯浪人 2020-11-22 06:50

Not to long ago, someone told me that long are not 64 bits on 64 bit machines and I should always use int. This did not make sense to me. I have se

7条回答
  •  长发绾君心
    2020-11-22 07:06

    The easiest way to get to know it for your compiler/platform:

    #include 
    
    int main() {
      std::cout << sizeof(long)*8 << std::endl;
    }
    

    Themultiplication by 8 is to get bits from bytes.

    When you need a particular size, it is often easiest to use one of the predefined types of a library. If that is undesirable, you can do what often happens with autoconf software and have the configuration system determine the right type for the needed size.

提交回复
热议问题