Closed
Description
Description
When experimenting with LTO, the compiler has flagged a number of situations where the same struct occurs in multiple files, with different definitions.
The naming of these structs should be scoped to avoid collisions.
This may also have undesirable effects in builds where both definitions of the conflicting types are used.
See: https://travis-ci.org/ARMmbed/mbed-os/jobs/467813686
./features/storage/kvstore/filesystemstore/FileSystemStore.cpp:54:3: warning: type 'struct key_iterator_handle_t' violates the C++ One Definition Rule [-Wodr]
} key_iterator_handle_t;
^
./features/storage/kvstore/securestore/SecureStore.cpp:73:3: note: a different type is defined in another translation unit
} key_iterator_handle_t;
^
./features/storage/kvstore/filesystemstore/FileSystemStore.cpp:52:11: note: the first difference of corresponding definitions is field 'dir_handle'
void *dir_handle;
^
./features/storage/kvstore/securestore/SecureStore.cpp:72:25: note: a field with different name is defined in another translation unit
KVStore::iterator_t underlying_it;
^
./features/storage/kvstore/filesystemstore/FileSystemStore.cpp:48:3: warning: type 'struct inc_set_handle_t' violates the C++ One Definition Rule [-Wodr]
} inc_set_handle_t;
^
./features/storage/kvstore/securestore/SecureStore.cpp:68:3: note: a different type is defined in another translation unit
} inc_set_handle_t;
^
./features/storage/kvstore/filesystemstore/FileSystemStore.cpp:44:11: note: the first difference of corresponding definitions is field 'key'
char *key;
^
./features/storage/kvstore/securestore/SecureStore.cpp:61:23: note: a field with different name is defined in another translation unit
record_metadata_t metadata;
^
./features/storage/kvstore/tdbstore/TDBStore.cpp:60:3: warning: type 'struct master_record_data_t' violates the C++ One Definition Rule [-Wodr]
} master_record_data_t;
^
./features/storage/nvstore/source/nvstore.cpp:66:3: note: a different type is defined in another translation unit
} master_record_data_t;
^
./features/storage/kvstore/tdbstore/TDBStore.cpp:58:14: note: the first difference of corresponding definitions is field 'tdbstore_revision'
uint16_t tdbstore_revision;
^
./features/storage/nvstore/source/nvstore.cpp:64:14: note: a field with different name is defined in another translation unit
uint16_t max_keys;
^
./features/storage/kvstore/tdbstore/TDBStore.cpp:66:3: warning: type 'area_state_e' violates the C++ One Definition Rule [-Wodr]
} area_state_e;
^
./features/storage/nvstore/source/nvstore.cpp:102:3: note: an enum with different value name is defined in another translation unit
} area_state_e;
^
[ERROR] ./features/storage/kvstore/filesystemstore/FileSystemStore.cpp:54:3: warning: type 'struct key_iterator_handle_t' violates the C++ One Definition Rule [-Wodr]
} key_iterator_handle_t;
^
./features/storage/kvstore/securestore/SecureStore.cpp:73:3: note: a different type is defined in another translation unit
} key_iterator_handle_t;
^
./features/storage/kvstore/filesystemstore/FileSystemStore.cpp:52:11: note: the first difference of corresponding definitions is field 'dir_handle'
void *dir_handle;
^
./features/storage/kvstore/securestore/SecureStore.cpp:72:25: note: a field with different name is defined in another translation unit
KVStore::iterator_t underlying_it;
^
./features/storage/kvstore/filesystemstore/FileSystemStore.cpp:48:3: warning: type 'struct inc_set_handle_t' violates the C++ One Definition Rule [-Wodr]
} inc_set_handle_t;
^
./features/storage/kvstore/securestore/SecureStore.cpp:68:3: note: a different type is defined in another translation unit
} inc_set_handle_t;
^
./features/storage/kvstore/filesystemstore/FileSystemStore.cpp:44:11: note: the first difference of corresponding definitions is field 'key'
char *key;
^
./features/storage/kvstore/securestore/SecureStore.cpp:61:23: note: a field with different name is defined in another translation unit
record_metadata_t metadata;
^
./features/storage/kvstore/tdbstore/TDBStore.cpp:60:3: warning: type 'struct master_record_data_t' violates the C++ One Definition Rule [-Wodr]
} master_record_data_t;
^
./features/storage/nvstore/source/nvstore.cpp:66:3: note: a different type is defined in another translation unit
} master_record_data_t;
^
./features/storage/kvstore/tdbstore/TDBStore.cpp:58:14: note: the first difference of corresponding definitions is field 'tdbstore_revision'
uint16_t tdbstore_revision;
^
./features/storage/nvstore/source/nvstore.cpp:64:14: note: a field with different name is defined in another translation unit
uint16_t max_keys;
^
./features/storage/kvstore/tdbstore/TDBStore.cpp:66:3: warning: type 'area_state_e' violates the C++ One Definition Rule [-Wodr]
} area_state_e;
^
./features/storage/nvstore/source/nvstore.cpp:102:3: note: an enum with different value name is defined in another translation unit
} area_state_e;
To test: Rebase #9080 on top of the fixes and verify that there are no "one definition rule" warnings.
Issue request type
[ ] Question
[ ] Enhancement
[X] Bug