Many many C/C++ programmers, even many of those employed by google, have a natural tendency to use a old C types like short/int...
Many many C/C++ programmers, even many of those employed by google, have a natural tendency to use a old C types like short/int/long etc. for integral types without thinking through X-platform issues or api interactions with other code. Also, size_t is a frustrating beast. It's meaning is dependent on the platform. The Single Unix spec only calls for size_t to be an unsigned integer type. Now imagine you're writing code to compile over multiple mobile platforms as well as on x86_64 on the server side. Can you tell me what is the largest number you can address with that type -- without getting into a long google/stackoverflow session or hitting the compiler manuals for each of those platforms? If you absolutely want to make sure that your type can handle the values you expect it to handle, better give it well defined types provided by stdint.h (uint32_t is sooo much better than just int or unsigned int or even size_t for this purpose). Now granted, you'd need to interact with external libraries (including libc/libc++) that'll want to use size_t etc. Not much you can do here but be very careful when passing data back and forth between your code and the library code. But that's been the lot of C coders since time began.
Posted by chetanahuja on Jul 8, 2015, 7:08 AM
Tags
Related issues
- Legit what one of our clients problem was.
- sounds painful, just searched on "how can i get ms office running in linux using wine" and the results included a containerised windows v...
- Appreciate MCP server availability, will help integrate with Claude.
- Maybe a different take, but as someone that manages a large public API that allows anonymous access, IPv6 has been a nightmare to try and...
- Why is there no write through unionfs in Linux?
- > why is there no in-memory kafka server that I can use for simple testing purposes https://github.com/embeddedkafka/...
Raise real-world problems, find people facing the same issue, and discuss solutions.5,500 issues0 comments
hackernews (Sysadmin)
Legit what one of our clients problem was.
sounds painful, just searched on "how can i get ms office running in linux using wine" and the results included a containerised windows v...
Appreciate MCP server availability, will help integrate with Claude.
Maybe a different take, but as someone that manages a large public API that allows anonymous access, IPv6 has been a nightmare to try and...
Why is there no write through unionfs in Linux?
> why is there no in-memory kafka server that I can use for simple testing purposes https://github.com/embeddedkafka/...
> why is there no in-memory kafka server that I can use for simple testing purposes.
I went from daily driving mac and being very used to the desktop environment, and i am really hating everything i've tried in Linux.
Many many C/C++ programmers, even many of those employed by google, have a natural tendency to use a old C types like short/int...
Many many C/C++ programmers, even many of those employed by google, have a natural tendency to use a old C types like short/int/long etc. for integral types without thinking through X-platform issues or api interactions with other code. Also, size_t is a frustrating beast. It's meaning is dependent on the platform. The Single Unix spec only calls for size_t to be an unsigned integer type. Now imagine you're writing code to compile over multiple mobile platforms as well as on x86_64 on the server side. Can you tell me what is the largest number you can address with that type -- without getting into a long google/stackoverflow session or hitting the compiler manuals for each of those platforms? If you absolutely want to make sure that your type can handle the values you expect it to handle, better give it well defined types provided by stdint.h (uint32_t is sooo much better than just int or unsigned int or even size_t for this purpose). Now granted, you'd need to interact with external libraries (including libc/libc++) that'll want to use size_t etc. Not much you can do here but be very careful when passing data back and forth between your code and the library code. But that's been the lot of C coders since time began.
Comments (0)
No comments yet. Start the discussion.