"Module":"build_assert",
"Title":"build_assert - routines for build-time assertions",
"Author":"dinesh",
"Dependencies":[
]
"Description":[
{
"str":""
},
{
"str":"This code provides routines which will cause compilation to fail should some"
},
{
"str":"assertion be untrue: such failures are preferable to run-time assertions,"
},
{
"str":"but much more limited since they can only depends on compile-time constants."
},
{
"str":""
},
{
"str":"These assertions are most useful when two parts of the code must be kept in"
},
{
"str":"sync: it is better to avoid such cases if possible, but seconds best is to"
},
{
"str":"detect invalid changes at build time."
},
{
"str":""
},
{
"str":"For example, a tricky piece of code might rely on a certain element being at"
},
{
"str":"the start of the structure.  To ensure that future changes don't break it,"
},
{
"str":"you would catch such changes in your code like so:"
},
{
"str":""
},
{
"str":"Example:"
},
{
"str":"	char *foo_string(struct foo *foo)"
},
{
"str":"	{"
},
{
"str":"		// This trick requires that the string be first in the structure"
},
{
"str":"		BUILD_ASSERT(offsetof(struct foo, string) == 0);"
},
{
"str":"		return (char *)foo;"
},
{
"str":"	}"
},
]
