Skip to content

Instantly share code, notes, and snippets.

@BugsBeGone
BugsBeGone / bugs_be_gone_structure_test.c
Created April 1, 2019 10:46
x86 Android native structure tests (for Java Native Access: https://github.com/java-native-access/jna/issues/1079)
/* x86 linux (including Android) structure alignment test for JNA */
#include <assert.h> /* static_assert() */
#include <stddef.h> /* offsetof() */
/* My own simple test struct example: a 4-byte float and an 8-byte double.
* With a maximum alignment of 4 bytes, it should not require any padding and
* should always take up just 12 bytes, regardless of the order of members.
*/
typedef struct BugsBeGoneTestStructure {
float field1; /* offset: 0, size: 4, padding: 0 */