I am in need of some advice on how to setup my project. I'm building a static library and want to know if the way I'm using precompiled headers is correct before I go too far.
So far, my stdafx file is just including (for types like DWORD, etc.) and (for std::string).
I built a simple cpp/header combo called TestFuncs.cpp/h
TestFuncs.cpp:
#include "stdafx.h"
using namespace std;
void MyFunc(DWORD a, string b) {
// irrelevant
}
TestFuncs.h
#pragma once
void MyFunc(DWORD a, std::string b);
This code here compiles properly. The issue that I have is when I want to use this static library in another project, I would normally do #include "path_to_my_static_lib_project/TestFuncs.h"
However, the issue with this, is based upon TestFuncs.h, both DWORD and string would be unknown at the time, as they are types defined from the stdafx.h file.
One solution that I came up with (that I don't know it's correct to be doing so) is just including stdafx.h at the top of TestFuncs.h after the #pragma once. Now the project works file using precompiled headers or not.
Is this how it should be done, or is there a proper way of doing this?
Thank you.