The two enum(s) in this code - what exactly are they doing? Why are they not simply defined as long or short? When I debug this status is 4 bytes. What is error_code datatype??
// make this VB compatible... #pragma pack (4) #ifndef IntVB #define IntVB short #endif typedef struct tagCommStatus { enum Comm status; enum CommErr error_code; IntVB nChannel; IntVB x_comm; IntVB y_comm; IntVB t_comm; IntVB z_comm; }CommStatus;
statuscan only take on the values defined inenum Comm, which is defined elsewhere. Similarly, the membererror_codecan only take on the values defined inenum CommErr, which is also defined elsewhere. Yes, they could be replaced by a suitable integer type, but using theenumidentifies the possible legitimate values better than justintdoes. The size of anenumis up to the compiler — 4 bytes is a legitimate choice.