Is size_t the word size?

前端 未结 6 2117
有刺的猬
有刺的猬 2021-02-06 23:27

Is size_t the word size of the machine that compiled the code?

Parsing with g++, my compiler views size_t as an long unsigned int

6条回答
  •  梦谈多话
    2021-02-06 23:58

    Such definitions are all implementation defined. I would use the sizeof(char *), or maybe sizeof(void *), if I needed a best guess size. The best this gives is the apparent word size software uses... what the hardware really has may be different (e.g., a 32-bit system may support 64-bit integers by software).

    Also if you are new to the C languages see stdint.h for all sorts of material on integer sizes.

提交回复
热议问题