Header file throwing errors in one project, but no

2019-09-13 07:37发布

问题:

I'm trying to integrate two projects, and to that end am including header files from one into the other. I'm using visual studio 2008 express.

The line

int E4407B_PPM(int &);

is throwing errors in the new project, but the original project compiles just fine.

The error I'm getting:

error C2143: syntax error : missing ')' before '&'

Any ideas?

Edit: I ended up removing the lines that took parameters in by reference, and just insured that all functions were declared before they were used in the actual source file. I guess it was a C++/C thing.

回答1:

You are probably building the second project (or at least the source file) as straight C. Make sure the file has a .cpp extension or that you are forcing a C++ compile (you can use the /TP compile option to do that).

Edit You can specify it for a single file: Right click on the file in the solution explorer and select Properties. Click on the Advanced option under C/C++. Choose "Compile as C++ Code (/TP)" (second option in the page in my version of Visual Studio).