tags:

views:

214

answers:

2

Hi, i have two projects in CPP. one defines a function which i'd like to invoke from the other. i added reference to the first project. still i 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? thanks.

+1  A: 

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.

Greg Hewgill
A: 

you could probably just add this to the top of the .cpp file of the second project:

#include "first_project_header_file.h"
Nathan Fellman