Skip to content

Commit 9469a8d

Browse files
Leander SchultenLeander Schulten
authored andcommitted
no internal linkage in headers
If I want to export an struct that has a rfl::Field, this template references the changed function and therefore tries to reference a TU-local entity which is illegal. The stacktrace from gcc: In file included from /root/.vs/src2/out/build/x64-debug-linux/vcpkg_installed/x64-linux/include/rfl/Literal.hpp:14, from /root/.vs/src2/out/build/x64-debug-linux/vcpkg_installed/x64-linux/include/rfl/Field.hpp:8, from /root/.vs/src2/out/build/x64-debug-linux/vcpkg_installed/x64-linux/include/rfl/AddStructName.hpp:6, from /root/.vs/src2/out/build/x64-debug-linux/vcpkg_installed/x64-linux/include/rfl.hpp:10, from /root/.vs/src2/*****/lib/pdaLib/TestVariable.ixx:3: /root/.vs/src2/out/build/x64-debug-linux/vcpkg_installed/x64-linux/include/rfl/Tuple.hpp:229:7: error: 'using rfl::tuple_element_t = typename rfl::tuple_element<ix, typename std::remove_cvref<_Tp2>::type>::type' exposes TU-local entity 'struct rfl::tuple_element<ix, typename std::remove_cvref<_Tp2>::type>' 229 | using tuple_element_t = | ^~~~~~~~~~~~~~~ /root/.vs/src2/out/build/x64-debug-linux/vcpkg_installed/x64-linux/include/rfl/Tuple.hpp:216:8: note: 'struct rfl::tuple_element<ix, typename std::remove_cvref<_Tp2>::type>' refers to TU-local object 'ix' 216 | struct tuple_element; | ^~~~~~~~~~~~~ In file included from /root/.vs/src2/out/build/x64-debug-linux/vcpkg_installed/x64-linux/include/rfl/Literal.hpp:16: /root/.vs/src2/out/build/x64-debug-linux/vcpkg_installed/x64-linux/include/rfl/internal/find_index.hpp:40:17: note: 'ix' has no linkage and is declared within TU-local entity 'constexpr int rfl::internal::find_index()' 40 | constexpr int ix = wrap_fields<_field_name, Fields>( | ^~ /root/.vs/src2/out/build/x64-debug-linux/vcpkg_installed/x64-linux/include/rfl/internal/find_index.hpp:39:22: note: 'constexpr int rfl::internal::find_index()' declared with internal linkage 39 | constexpr static int find_index() { | ^~~~~~~~~~ /root/.vs/src2/out/build/x64-debug-linux/vcpkg_installed/x64-linux/include/rfl/Tuple.hpp:229:7: error: 'using rfl::tuple_element_t = typename rfl::tuple_element<ix, typename std::remove_cvref<_Tp2>::type>::type' exposes TU-local entity 'struct rfl::tuple_element<ix, typename std::remove_cvref<_Tp2>::type>' 229 | using tuple_element_t = | ^~~~~~~~~~~~~~~ /root/.vs/src2/out/build/x64-debug-linux/vcpkg_installed/x64-linux/include/rfl/Tuple.hpp:216:8: note: 'struct rfl::tuple_element<ix, typename std::remove_cvref<_Tp2>::type>' refers to TU-local object 'ix' 216 | struct tuple_element; | ^~~~~~~~~~~~~ /root/.vs/src2/out/build/x64-debug-linux/vcpkg_installed/x64-linux/include/rfl/internal/find_index.hpp:53:19: note: 'ix' has no linkage and is declared within TU-local entity 'constexpr int rfl::internal::find_index_or_minus_one()' 53 | constexpr int ix = wrap_fields<_field_name, Fields>( | ^~ /root/.vs/src2/out/build/x64-debug-linux/vcpkg_installed/x64-linux/include/rfl/internal/find_index.hpp:49:22: note: 'constexpr int rfl::internal::find_index_or_minus_one()' declared with internal linkage 49 | constexpr static int find_index_or_minus_one() { | ^~~~~~~~~~~~~~~~~~~~~~~
1 parent 594707d commit 9469a8d

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

include/rfl/internal/find_index.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ constexpr auto wrap_fields(std::integer_sequence<int, _is...>) {
3636

3737
/// Finds the index of the field signified by _field_name
3838
template <StringLiteral _field_name, class Fields>
39-
constexpr static int find_index() {
39+
constexpr int find_index() {
4040
constexpr int ix = wrap_fields<_field_name, Fields>(
4141
std::make_integer_sequence<int, rfl::tuple_size_v<Fields>>());
4242
static_assert(rfl::tuple_element_t<ix, Fields>::name_ == _field_name,
@@ -46,7 +46,7 @@ constexpr static int find_index() {
4646

4747
/// Finds the index of the field signified by _field_name or -1.
4848
template <StringLiteral _field_name, class Fields>
49-
constexpr static int find_index_or_minus_one() {
49+
constexpr int find_index_or_minus_one() {
5050
if constexpr (rfl::tuple_size_v<Fields> == 0) {
5151
return -1;
5252
} else {

0 commit comments

Comments
 (0)