From: JD on
Hi,

I know it sounds against the object oriented concept. Is it possible to
share a global variable among dlls? I am a OO faithful guy. However, in
some very rare situations, a globally shared variable among dlls is a good
solution to reduce complexity, if it's possible.

Thanks.
JD




From: David Lowndes on
>I know it sounds against the object oriented concept. Is it possible to
>share a global variable among dlls?

Yes, it's possible to export/import a variable.

In the MSDN topic titled "INFO: Using _declspec(dllimport) &
_declspec(dllexport) in Code" see the section "Using
_declspec(dllexport) and _declspec(dllimport) on Data"

Dave
From: JD on
Thanks Dave. I just went to read the article you quoted. Can we export a
variable from a dll to another dll that is dependent on the first dll? For
example, can we export a variable in .exe back to a dependent dll?

Thanks for any further help.
JD


"David Lowndes" <DavidL(a)example.invalid> wrote in message
news:e0fk145knj84r9gjg89kh0npt3thbgimc2(a)4ax.com...
> >I know it sounds against the object oriented concept. Is it possible to
>>share a global variable among dlls?
>
> Yes, it's possible to export/import a variable.
>
> In the MSDN topic titled "INFO: Using _declspec(dllimport) &
> _declspec(dllexport) in Code" see the section "Using
> _declspec(dllexport) and _declspec(dllimport) on Data"
>
> Dave


From: David Lowndes on
>Thanks Dave. I just went to read the article you quoted. Can we export a
>variable from a dll to another dll that is dependent on the first dll? For
>example, can we export a variable in .exe back to a dependent dll?

I don't know for sure as I've never needed to do it - give it a try!

Dave
From: Doug Harrison [MVP] on
On Thu, 1 May 2008 15:41:45 -0700, "JD" <jdt_young(a)yahoo.com> wrote:

>Can we export a
>variable from a dll to another dll that is dependent on the first dll? For
>example, can we export a variable in .exe back to a dependent dll?

You can do that with functions by using GetProcAddress. Don't know about
variables. Accomplishing this with implicit linking is going to be harder,
because you have to solve the cyclic dependency in some way.

--
Doug Harrison
Visual C++ MVP