|
-
September 4th, 2009, 12:49 AM
#1
how to access a variable from another project in the current project
Hello...
I have two projects.. ProjA and ProjB.. ProjA is main executable project and ProjB is compiled into a .lib file and used in ProjA.
Now, there is a member in the main app file of ProjA called current_transformation.. I need to set or change current_transformation's value in ProjB depending on certain criteria..
How do i do that without copying all files from PrajB to ProjA..??
Thanks in advance
-
September 4th, 2009, 02:32 AM
#2
Re: how to access a variable from another project in the current project
Hm....can't you just add a Get() and Set() function to the lib's class? I take it you have an instance of the class holding the variable in the other project?
If the lib isn't yours, and you're just given a lib and an h file, then it will be a problem unless the variable is public.
-
September 4th, 2009, 03:33 AM
#3
Re: how to access a variable from another project in the current project
No No..
I got two projects.. along with source code. One is compiled into Lib file and other is compiled into .exe file.. Now i want to write a set statement in lib project, which will set a variable present in exe project...
i hope you got my problem...
-
September 4th, 2009, 04:07 AM
#4
Re: how to access a variable from another project in the current project
Ah...hm, how about having a pointer to the exe's variable that the lib initializes to null.
Then when the exe initializes, it sets that pointer to &exe_variable.
Then whenever the lib needs to access the variable, it can do
if (pExe_Variable)
SomeVar=*pExe_Variable; or *pExe_Variable = SomeVar;
Would that work?
Or maybe when the exe initializes the class in question from the lib it could add a pointer to itself:
pLibClass = new LibClass(this);
and then the lib class could have
pExeClass->Get() or pExeClass->Set(SomeVar);
I don't know if the exe class will need to derive from a small class in the lib (that you then cast to) containing Get, Set and perhaps variable.
Just a thought. Hope it's useful in some way :-)
-
September 4th, 2009, 06:38 AM
#5
Re: how to access a variable from another project in the current project
i am using visual C++.. i added both projects in a single workspace and included main file of exe project in the respective file of lib project and gave all the required include directory paths..
It worked finally..
Thanks anyways..
-
September 4th, 2009, 01:01 PM
#6
Re: how to access a variable from another project in the current project
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|