Thanks for the suggestions.

@mratsim Your solution seems to work fine for me too, only drawbacks are that 
the nim modules that want to use **cpp_tools** are forced to use include rather 
than import and also all modules depend on those module and so forth (include 
needs to cascade upwards in the module dependency tree)

Also this in turn means that the c++ template<> code will be generated & 
repeated in each of those modules. I think it depends on the size of the c++ 
template<> code if this is a bad thing, since on one hand it saves the c++ 
compiler from handling any #include directives (because the code is just 
inlined into all .cpp files directly). On the other hand if the c++ template 
code might get very complex (i.e. thousands of lines of c++ template code) it 
might slow down the c++ compiler because of all the duplicate 
lexing/parsing/etc.

@gemath Thanks for the hint ... I realize I might have made my above example 
too simple though 😅 ... In my actual code the **sizeof_init** macro does not 
just emit a static string literal in its emit pragma ... the actual string is 
itself composed by some nim logic during compile time. Therefore it can not 
easily be extracted via copy&paste into a c++ header file. However, might it be 
possible to generate & save such a file in nim during the compile time anyway 
via file I/O APIs ? ... I will have to investigate that

Thanks

Reply via email to