I have two projects in CPP. One defines a function which I'd like to invoke from the other. I added a reference to the first project. I still get the message of "identifier not found". Assuming that the CPP file in the first project doesn't have a header, how do I make the second project know about its functions?
Ofer
问问题
1664 次
2 回答
1
If the first project doesn't have a header and you don't want to add one, then use the extern
keyword to declare a prototype for the function you want to call in the second project source:
extern function_in_first_project(int args_go_here);
Make 100% sure that the function declaration (including argument list and calling convention) matches that of the actual function or you'll run into further problems.
This may not be the only thing you have to do to make your project link, depending on how you've got your projects set up.
于 2008-10-18T10:11:46.497 回答
0
您可能只需将其添加到第二个项目的 .cpp 文件的顶部:
#include "first_project_header_file.h"
于 2008-10-19T11:36:08.883 回答