I asked this question Type with a guaranteed size of 2? on here and soon got flooded and downvoted by people explaining that they want to see reasoning for my question and apparently I was rude when I pointed out that, in my opinion, one does not need to defend why he asked a question.
For the sake of spelling it out, I later added my reasoning: Pure curiosity
I understand that there are nonsense questions - where the asker doesn't understand the underlying concept of a topic and thus asks questions that just can't be answered.
In this the case though, the question was quite clear and there is no fundamental misunderstanding of the topic.
Is there an (possibly optional) integral type with the property >sizeof(mysterious_type) == 2 for whatever system is defined on?
I want to understand the reason why several people - apparently - thought that the question is off-topic or not useful. I realized this is a bad question to ask, because the answer is quite simple - they dislike the question.
After thinking about it some time and to make it more suitable for the [discussion] tag, please add your opinion on
How to correctly ask a curiosity driven question?
char
doesn't consist from 8 bits, that type is obviouslyint16_t
/uint16_t
. That might be reasons for the downvotes actually.sizeof(type) == 2
. That is not 2 bytes, that is2*sizeof(char)
. Obviously notint16_t
(as pointed out by @T.C. in the comments and yourself: "systems where char doesn't consist from 8 bits") Then, MCVE for a curiosity question where I don't know if it is possible beforehands? Now how do you expect me to give that?htons()
/ntohs()
functions family, you don't need to roll your own endianess testing usually. I also remember that there was a compiler intrinsic define value, that can be used.