1 solution, 2 projects: how to use function form project B into project A

  • Thread starter Thread starter unknown;
  • Start date Start date
U

unknown;

hello,

i've got a question about using a function from project B in project A.
The projects are both in the same solution (using Microsolft Visual
Studio 2005)
the projects ara both native C++.

i've already added a reffrence from projectB into projectA.

i've got a function in projectA:
mainClass.cpp:
int main ()
{
int i = 0;
// i want to use function from project B like this:
// i = functionFromProjectB (10);
return i;
}


and in project B:
fileX.cpp:
int functionFromProjectB (int i)
{
return i * 4;
}



i know, the example is a little stange but it may be usefull to explain
my problem.

my question is how to do this or is this a .NET functionality and not
possible with native C++ projects.
 
unknown; said:
hello,

i've got a question about using a function from project B in project A.
The projects are both in the same solution (using Microsolft Visual
Studio 2005)
the projects ara both native C++.

i've already added a reffrence from projectB into projectA.

i've got a function in projectA:
mainClass.cpp:
int main ()
{
int i = 0;
// i want to use function from project B like this:
// i = functionFromProjectB (10);
return i;
}


and in project B:
fileX.cpp:
int functionFromProjectB (int i)
{
return i * 4;
}



i know, the example is a little stange but it may be usefull to explain
my problem.

my question is how to do this or is this a .NET functionality and not
possible with native C++ projects.

unknown;:

Are you related to IUnknown?

The easiest thing to do is just to add fileX.cpp to both projects. Of
course that means it will be compiled twice if you change it (unless you
make the output directories the same).

David Wilkinson
 
i've got a question about using a function from project B in project A.
The projects are both in the same solution (using Microsolft Visual
Studio 2005)
the projects ara both native C++.

i've already added a reffrence from projectB into projectA.

i've got a function in projectA:
mainClass.cpp:
int main ()
{
int i = 0;
// i want to use function from project B like this:
// i = functionFromProjectB (10);
return i;
}


and in project B:
fileX.cpp:
int functionFromProjectB (int i)
{
return i * 4;
}



i know, the example is a little stange but it may be usefull to explain
my problem.

my question is how to do this or is this a .NET functionality and not
possible with native C++ projects.

Hi,

References are only useful for .NET projects.
If the second project is a library project, simply make it a dependency
of your other project and include the appropriate header files.

If the projects are not related in that way, you can simply add the
appropriate cpp file to your project.
That way the file gets compiled twice.

--

Kind regards,
Bruno van Dooren
(e-mail address removed)
Remove only "_nos_pam"
 
Back
Top