Skip to content

Commit 7194e3e

Browse files
committed
SpiNorFlash: use C++ style struct in C++ only header
`SpiNorFlash.h` is a C++ header, but the `Identification` struct is created in a C style using `typedef struct`. Clang issues a warining about this discrepancy: ``` In file included from /home/nero/repos/pinetime/InfiniSim/InfiniTime/src/systemtask/SystemTask.cpp:13: /home/nero/repos/pinetime/InfiniSim/sim/drivers/SpiNorFlash.h:16:21: warning: anonymous non-C-compatible type given name for linkage purposes by typedef declaration; add a tag name here [-Wnon-c-typedef-for-linkage] typedef struct __attribute__((packed)) { ^ Identification /home/nero/repos/pinetime/InfiniSim/sim/drivers/SpiNorFlash.h:17:9: note: type is not C-compatible due to this default member initializer uint8_t manufacturer = 0; ^~~~~~~~~~~~~~~~~~~~ /home/nero/repos/pinetime/InfiniSim/sim/drivers/SpiNorFlash.h:20:9: note: type is given name 'Identification' for linkage purposes by this typedef declaration } Identification; ^ 1 warning generated. ``` The easy fix is to use a C++ style struct. Same fix as in: InfiniTimeOrg/InfiniTime#1046
1 parent 7110fa0 commit 7194e3e

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

sim/drivers/SpiNorFlash.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ namespace Pinetime {
1313
SpiNorFlash(SpiNorFlash&&) = delete;
1414
SpiNorFlash& operator=(SpiNorFlash&&) = delete;
1515

16-
typedef struct __attribute__((packed)) {
16+
struct __attribute__((packed)) Identification{
1717
uint8_t manufacturer = 0;
1818
uint8_t type = 0;
1919
uint8_t density = 0;
20-
} Identification;
20+
};
2121

2222
Identification ReadIdentificaion();
2323
uint8_t ReadStatusRegister();

0 commit comments

Comments
 (0)