Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Depends.

If you use size_t all the time, you may forget or have someone else forget that another system isn’t the same.

If you always use uint8_t or int64_t etc there is no ambiguity. If I intended this to be an 32bit var, it will be regardless if who is compiling it.



But this is an allocation function, where the amount of data to be allocated is specified in bytes. That must surely use size_t. Imagine the case where 128 bit systems become popular and you want to use this function to allocate 2^70 bytes of memory. Using uint64_t here would be invalid in that case.


If you’re going to allocate like that you could use 8s and get any multiple you like, no?

I’ll give you that there are times for performance you want the native system type. But I would still prefer to use uint32_t and specify this was optimized for a 32bit system.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: