Is there any special significance to defining constant data insi开发者_运维问答de a structure as shown. This is from a 3rd party library.
typedef struct
{
IntVB abc_number;
#define ABC_A 0x01
#define ADBC_E 0x02
IntVB asset;
} StructA;
Not really. They probably provide better significance to the programmer in that spot of the code.
Meaning that those constants are probably related to the items in that struct container, or to the behavior of the struct.
Agree with @Luca Matteis. They are probably defined there because they are relevant at that point in the code. The compiler doesn't treat them specially. In particular, they could be defined just before that structure and work just the same. There's no significance to them being inside it.
However, there is one thing to note, they are only valid after they are defined. So they can't be used earlier in the file. That could be significant. For instance, they could be defined differently before that point. (It's a bad idea to do that, but it's possible.)
No, they could be called without any scope
精彩评论