Hope you're doing great. We're stumbling upon a compiler warning about taking an address of a packed member in this library. We think we're facing an issue with this in our application. Without going much further in said application (which I can not share), I'll now give a more detailed description of the warning.
When compiling any application with this library included and the Adafruit nRF52832 Feather selected as board, one is presented with the warning underneath.
C:\Program Files (x86)\Arduino\libraries\SD\src\utility\SdFile.cpp: In member function 'uint8_t SdFile::open(SdFile*, const char*, uint8_t)':
C:\Program Files (x86)\Arduino\libraries\SD\src\utility\SdFile.cpp:532:15: warning: taking address of packed member of 'directoryEntry' may result in an unaligned pointer value [-Waddress-of-packed-member]
532 | dateTime_(&p->creationDate, &p->creationTime);
| ^~~~~~~~~~~~~~~~
C:\Program Files (x86)\Arduino\libraries\SD\src\utility\SdFile.cpp:532:15: warning: taking address of packed member of 'directoryEntry' may result in an unaligned pointer value [-Waddress-of-packed-member]
C:\Program Files (x86)\Arduino\libraries\SD\src\utility\SdFile.cpp:532:33: warning: taking address of packed member of 'directoryEntry' may result in an unaligned pointer value [-Waddress-of-packed-member]
532 | dateTime_(&p->creationDate, &p->creationTime);
| ^~~~~~~~~~~~~~~~
C:\Program Files (x86)\Arduino\libraries\SD\src\utility\SdFile.cpp:532:33: warning: taking address of packed member of 'directoryEntry' may result in an unaligned pointer value [-Waddress-of-packed-member]
C:\Program Files (x86)\Arduino\libraries\SD\src\utility\SdFile.cpp: In member function 'uint8_t SdFile::sync(uint8_t)':
C:\Program Files (x86)\Arduino\libraries\SD\src\utility\SdFile.cpp:1155:17: warning: taking address of packed member of 'directoryEntry' may result in an unaligned pointer value [-Waddress-of-packed-member]
1155 | dateTime_(&d->lastWriteDate, &d->lastWriteTime);
| ^~~~~~~~~~~~~~~~~
C:\Program Files (x86)\Arduino\libraries\SD\src\utility\SdFile.cpp:1155:17: warning: taking address of packed member of 'directoryEntry' may result in an unaligned pointer value [-Waddress-of-packed-member]
C:\Program Files (x86)\Arduino\libraries\SD\src\utility\SdFile.cpp:1155:36: warning: taking address of packed member of 'directoryEntry' may result in an unaligned pointer value [-Waddress-of-packed-member]
1155 | dateTime_(&d->lastWriteDate, &d->lastWriteTime);
| ^~~~~~~~~~~~~~~~~
C:\Program Files (x86)\Arduino\libraries\SD\src\utility\SdFile.cpp:1155:36: warning: taking address of packed member of 'directoryEntry' may result in an unaligned pointer value [-Waddress-of-packed-member]
I would've opened a pull-request if I new what the reason is for it being a packed member in the first place. I don't see any obvious reasons as to why you'd want that in this case; not every byte counts in this situation I suppose?
Hi there!
Hope you're doing great. We're stumbling upon a compiler warning about taking an address of a packed member in this library. We think we're facing an issue with this in our application. Without going much further in said application (which I can not share), I'll now give a more detailed description of the warning.
When compiling any application with this library included and the Adafruit nRF52832 Feather selected as board, one is presented with the warning underneath.
I would've opened a pull-request if I new what the reason is for it being a packed member in the first place. I don't see any obvious reasons as to why you'd want that in this case; not every byte counts in this situation I suppose?
I propose to make the struct not packed.
Kind regards,
Jochem