I started out with one long header file and one long source file (I inherited a messy project and wanted to get going on my work ASAP). Now it was "finished" and I decided to split it for orderliness sake (make it more manageable in case I need to update it in the future.
I separated it in stages, and all went well and at one point I keep getting error C2146 (which basically says that the type is not specified).
Before I had the following situation:
MyAlg.h
#pragma once
#include <string>
using namespace std;
struct AlgParams {
int param1;
int param2;
};
void ParseParamFile(AlgParams& params, string& file_name);
The function ParseParamFile
was defined in MyAlg.cpp
. The main project files were
MyApp.h
#include "MyAlg.h"
#include <string>
using namespace std;
struct AppParams {
string inputFileName;
string paramFileName;
AlgParams AlgPrm; // Note that the global parameter struct has
}; // an AlgParams
MyApp.cpp
#include "MyApp.h"
void RunMyAlg(SomeClass& data, AlgParams& params) {
--- bla bla bla
}
void ParseCommandLine(char* argv, AppParams& params) {
--- bla bla bla
}
int main(int argc, char* argv)
{
AppParams params;
ParseCommandLine(argv, params);
ParseParamFile(params, params.paramFileName);
//// some code to create and load algorithm data ////
RunMyAlg(data, params.AlgPrm);
return SUCCESS;
}
I then moved the definition of RunMyAlg
to MyAlg.cpp
(and created a declaration in MyAlg.h
). Since then it won't compile, giving me:
error C2146: syntax error : missing ';' before identifier 'AlgParams' in the relevant line of
MyApp.h
.
What could be causing this? Is there a way to get a report of compilation order in Visual Studio Express?