union arbelprm_mad mad_ifc;
int rc;
- linker_assert ( sizeof ( *mad ) == sizeof ( mad_ifc.mad ),
- mad_size_mismatch );
+ /* Sanity check */
+ static_assert ( sizeof ( *mad ) == sizeof ( mad_ifc.mad ) );
/* Copy in request packet */
memcpy ( &mad_ifc.mad, mad, sizeof ( mad_ifc.mad ) );
union hermonprm_mad mad_ifc;
int rc;
- linker_assert ( sizeof ( *mad ) == sizeof ( mad_ifc.mad ),
- mad_size_mismatch );
+ /* Sanity check */
+ static_assert ( sizeof ( *mad ) == sizeof ( mad_ifc.mad ) );
/* Copy in request packet */
memcpy ( &mad_ifc.mad, mad, sizeof ( mad_ifc.mad ) );
static int script_probe ( struct image *image ) {
static const char ipxe_magic[] = "#!ipxe";
static const char gpxe_magic[] = "#!gpxe";
- linker_assert ( sizeof ( ipxe_magic ) == sizeof ( gpxe_magic ),
- magic_size_mismatch );
+ static_assert ( sizeof ( ipxe_magic ) == sizeof ( gpxe_magic ) );
char test[ sizeof ( ipxe_magic ) - 1 /* NUL */
+ 1 /* terminating space */];
} \
} while ( 0 )
+/**
+ * Assert a condition at build time
+ *
+ * If the compiler cannot prove that the condition is true, the build
+ * will fail with an error message.
+ */
+#undef static_assert
+#define static_assert(x) _Static_assert( x, #x )
+
/**
* Assert a condition at link-time.
*
struct aoeata *aoeata = &aoehdr->payload[0].ata;
/* Sanity check */
- linker_assert ( AOE_FL_DEV_HEAD == ATA_DEV_SLAVE, __fix_ata_h__ );
+ static_assert ( AOE_FL_DEV_HEAD == ATA_DEV_SLAVE );
assert ( len == ( sizeof ( *aoehdr ) + sizeof ( *aoeata ) +
command->data_out_len ) );