Doxygen Documentation |
||||||
Package: |
PBI |
|||||
Version: |
V0-0-3 |
Marked: |
(not marked) |
|||
Constituent: |
doc_gather |
Tag: |
sun-gcc |
This graph shows which files directly or indirectly include this file:
Defines | |
#define | COUNT_OF(_array) (sizeof (_array) / sizeof (*(_array))) |
Returns a count of the number of elements in _array. | |
#define | OFFSET_OF(_structure, _member) ((unsigned int) &(((_structure *) 0) -> _member)) |
Returns the byte offset of _member within the named structure or typedef _structure. |
CVS $Id: Ofs.h,v 1.1.1.1 2003/05/20 18:47:37 russell Exp $
|
Returns a count of the number of elements in _array.
int array[40]; int count; . count = COUNT_OF(array);
#define NBUF 512 . . char buffer[NBUF]; int count; count = NBUF; This is potentially dangerous if, for example, someone slips in
#define NBUF 512 . . char buffer[2*NBUF]; int count; . count = NBUF; particularly if the line declaring the buffer and the line getting the count are physically separated in the code. Bottom line is that COUNT_OF ALWAYS returns the correct number of the elements in an array whose size is known at compile time. |
|
Returns the byte offset of _member within the named structure or typedef _structure.
typedef struct _X { int a; int b; int c; } X; X *x; int offset_a = OFFSET_OF (X, a); int offset_b = OFFSET_OF (struct _X, b); int offset_c = OFFSET_OF (typeof (*x), c);
|