I use MSVC2017 (with MSVC2013 toolchain, if it's matters). So, I have created new solution with "static lib" project and a console app. At this step it works.
Now, I changed some project's paths for the lib project:
Output directory: $(SolutionDir)BuildDebug
Intermediate directory: $(OutDir)\Debug
I added following includes into pch.h:
- #include <windows.h>
- #include <inttypes.h>
- #include <cstdlib>
- #include <stdexcept>
I added reference to my lib and lib's include dir inside console app. Now Studio cannot compile my project, showing a lot of errors about
error C2061: syntax error: identifier 'LONG'
and related. I found that there is no .pch file anywhere. I also created test solution with same static lib alone and changed same paths. It seems to compiling successfully, but Intellisense underlines "LONG" with red, saying "it's undefined". May be someone faced the same problem.
Update: I just tried to create a new solution. I added static lib project, then I added simple file with single function int func(LONG v)
. It seems to compile. But then I add console app to the solution, link it against static lib, and it's not compile, saying that
error C2065: 'LONG': undeclared identifier
Update 2: I've found that static lib files don't see <windows.h> added into precompiled header. So I included it into my header directly and added typedef struct IUnknown IUnknown;
before windows.h, because of new error related to IUnknown
. It seems to work. But I still don't understand what is going on.