Всегда ли sizeof (enum) == sizeof (int)?

Всегда ли sizeof (enum) == sizeof (int)?

Or is it compiler dependent? Is it wrong to say, as compiler are optimized for word lengths (memory alignment) ie y int is the word-size on a particular compiler? Does it means that there is no processing penalty if I use enums, as they would be word aligned? Is it not better if I put all the return codes in an enum, as i clearly do not worry about the values it get, only the names while checking the return types. If this is the case wont #DEFINE be better as it would save memory.

Какова обычная практика? Если мне нужно передать эти типы возвращаемых данных по сети, и некоторая обработка должна быть выполнена на другом конце, что бы вы предпочли enums / # define / const ints.

РЕДАКТИРОВАТЬ - Просто проверяя в сети, поскольку complier не символически связывает макросы, как тогда люди отлаживают, сравнивают целочисленное значение с файлом заголовка?

Из ответов & # x2014; я добавляю эту строку ниже, так как мне нужны пояснения & # x2014;

"So it is implementation-defined, and sizeof(enum) might be equal to sizeof(char), i.e. 1."

Does it not mean that compiler checks for the range of values in enums, and then assign memory. I don't think so, of course I don't know. Can someone please explain me what is "might be".

Ответы на вопрос(5)

Ваш ответ на вопрос