-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Am 2015-03-03 um 12:18 schrieb Matteo Bruni:
AFAIK C doesn't give any guarantee on a specific allocation of bitfields in memory. I'm sure this works in practice with GCC and maybe also with the other compilers we care about, but if it doesn't get too ugly I'd prefer explicit shifts and masks and be safe. My C / C++ book agrees with you. The compiler is free to add padding. We can force the compiler to add padding, but not prevent it from doing so. As much as I liked the idea of using a struct here it won't reliably work.
C++ adds a few more features to bitfields, but we don't use C++. -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBAgAGBQJU9vsnAAoJEN0/YqbEcdMw/0QQAJfup4IZdnkwlLlHpE3Dos8A yECipvqtQBtjqzBemKCtCY6BAvnlX5myOo03pR7dQmF2rNKHye+BnF4vBvconZKn Ni+DdczAeu+2wvd43L2rbl0wRq8G8mFHJpF3F6q3Ytr2uF6r5axct3yxGxHK7TqQ K+Y+a1d65wfvj13vtDg7ZOeAjvKM7nx6Qa350SG3Oay/c7HsayD2X2jVF8NpiBbM 022i6zz2GPuEwAjCfXpvqX2NaBthHV6kG6WwhHuK0pRUZd0tNNpUI4DdLOM/6x0m pTzAx/7+YwUcN+D5dW/ZdttX3v7OBRK4h3d2pMaye1UwQ6sh6UpRYDwHU3Fhv8Cr zbOHU7gYhyFmSf3iZygMz7/RAAMp9BROsRFAh4lLEkG863xVVjT3qZv3/QE87ncn l2Q3Up/C3PJJXulJpd5/uKt3TejgkGIJyDKfnSQsHHyV5OloZxt6ZcS9gTHjTeqa 4Ouw0G638PqbIrxetO7ASONksxdT11kT9+CoPNg0zJWJD43Syc3hujJLH6RwEi/1 D5zrkbUM3EwfiFXbF/ZljK4w+EGuWoH5mm759R34hilC/yHgX0scS5VlwvH3uz9o bpDOy9cXF9ScD8tUPQISbNOc2lhWBcLK/NghaXyvksfMN8LrRxieqptCq519L10Z 2VSMxwLmTN+cc/4KksEP =eoL1 -----END PGP SIGNATURE-----