I have a situation where another developer is including source files from a project that I maintain in a project that he maintains. The nature of the files is such that each source file registers a ‘command’ in an interpretive environment so all you have to do is link in a new source file to register a new ‘command’. We can’t put these files in a static library because, unless the project makes explicit reference to the symbols in the file, the linker will optimise the file away.
It seems like a potential solution is to have a file external to both projects that ‘includes’ a list of source file names in both projects. The problem is that I have no idea whether or how this could be done. Suggestions, anyone?
There is no reason a source file can’t be in multiple projects. Just add it as an ‘existing item’ in VS.
If you are using precompiled headers then both projects will need equivalent set ups for this to work.
You can also use a #pragma in a lib to force a symbol to be included when the linker would otherwise discard it.
See the MSDN document for #pragma comment and the include option