 
                            ...
| Code Block | ||||
|---|---|---|---|---|
| 
 | ||||
| #include <stddef.h> #pragma pack(1) //* 1 byte */ struct test{ Â int int a; char b; int c; }; /* ... safely copy bytes to user space ... */ extern int copy_to_user(void *dest, void *src, size_t size); void do_stuff(void *usr_buf) { struct test arg = {.a=1,.b=2,.c=3}; /* .. . // perform operationoperations on arg . . // Copy ... */ /* copy arg to user space */ copy_to_user(ptrusr_buf, &arg, sizeof(arg)); /* ... */ } | 
pack takes effect at the first struct declaration after the pragma is seen. The alignment of a member will be on a boundary that is a multiple of 1 byte.
...