1) I want to use variable n_threads inside my library code (that is distributed in shared library form on Windows and Linux) in multiple .cpp files.
2) I want to make library user to set it.
How to do such thing in C++?
- I tried global file with
staticvariables - it leads to each.cppfile having its copy; - I have tried just to keep it in a namespace which leads to variable being already defined in other translation units and thus library not compiling
- I have tried
external(which works on Linux with.soand does compile on Windows MSVC14) which leads to library not compiling due to unresolved externals.
What can be done to make global variable used in multiple library .cpp files be setable from outside (from library user code)?