Skip to content

Commit

Permalink
Fixes sequence problem when more than one CDI file gets rendered. (#601)
Browse files Browse the repository at this point in the history
* Fixes sequence problem when more than one CDI file gets rendered.

Due to specific rules on partial template specializations, the C++ compiler would emit an error
depending on which order the RENDER_CDI invocatoins were listed in the source file
of config.hxx, incliuding being sensitive to different order of #include lines.

This is fixed by allowing only every second integer to be partially specialized.

* Remove dead code.
  • Loading branch information
balazsracz authored Jan 15, 2022
1 parent 9ed634f commit 456945f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
12 changes: 2 additions & 10 deletions src/openlcb/CompileCdiMain.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,8 @@ int main(int argc, char *argv[])
)");
}

render_all_cdi<10>();
/* render_all_cdi<9>();
render_all_cdi<8>();
render_all_cdi<7>();
render_all_cdi<6>();
render_all_cdi<5>();
render_all_cdi<4>();
render_all_cdi<3>();
render_all_cdi<2>();
render_all_cdi<1>();*/
// Internally calls all smaller numbered instances all the way down to 1.
render_all_cdi<20>();

std::vector<unsigned> event_offsets;
openlcb::ConfigDef def(0);
Expand Down
4 changes: 2 additions & 2 deletions src/openlcb/ConfigRepresentation.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -502,11 +502,11 @@ template <> inline void render_all_cdi<0>()
* @param N is a unique integer between 2 and 10 for the invocation.
*/
#define RENDER_CDI(NS, TYPE, NAME, N) \
template <> inline void render_all_cdi<N>() \
template <> inline void render_all_cdi<2 * N>() \
{ \
NS::TYPE def(0); \
render_cdi_helper(def, #NS, NAME); \
render_all_cdi<N - 1>(); \
render_all_cdi<2 * N - 1>(); \
}

#endif // _OPENLCB_CONFIGREPRESENTATION_HXX_

0 comments on commit 456945f

Please sign in to comment.