Dfi-CheckMacros.hh File Reference
Defines a set of macros which checks consistency between Q-defined structures and their DFI equivalents.
More...
#include <PBI/Check.h>
|
Defines |
#define | offsetof(c, m) ((unsigned int)&(((c*)1)->m)-1) |
#define | size_of(c, m) sizeof (((c*)1)->m) |
#define | Check_Size(_class, _struct) CHECK(Size_ ## _class, (sizeof(_class) == sizeof (_struct))) |
#define | CONDITION(_class, _struct, _member) |
#define | CONDITION2(_class, _cmember, _struct, _smember) |
Detailed Description
Defines a set of macros which checks consistency between Q-defined structures and their DFI equivalents.
- Author:
- JJRussell - russell@slac.stanford.edu
CVS $Id: Dfi-CheckMacros.hh,v 1.2 2011/03/29 20:58:46 russell Exp $
- The rules of the game are the DFI is allowed to import and use Q-defined data structures, but they are not allowed to export them. In practice this means Q include file may be used in the src directory but not the DFI/ directory. In some cases, it is convenient to export the these structures. To do this consistent with the above rules, one is obligated to replicate the Q structure in DFI. The macros definied in here help to some large measure to ensure the replication is faithful. They can be used to check the sizes and offsets of field members is the same between the two. The one thing it cannot do is to ensure bit field structures are laid out consistently. Let the buyer beware.
Define Documentation
#define CONDITION |
( |
_class, |
|
|
_struct, |
|
|
_member |
|
) |
|
Value:
((offsetof(_class, _member) == offsetof(_struct, _member) \
&& (size_of (_class, _member) == size_of (_struct, _member))))
#define CONDITION2 |
( |
_class, |
|
|
_cmember, |
|
|
_struct, |
|
|
_smember |
|
) |
|
Value:
((offsetof(_class, _cmember) == offsetof(_struct, _smember) \
&& (size_of (_class, _cmember) == size_of (_struct, _smember))))