Article View: borland.public.cppbuilder.nativeapi
Article #17010static variables of a Class inside a DLL
From: Gianstefano Monni
Date: Mon, 14 Apr 2003 07:14
Date: Mon, 14 Apr 2003 07:14
42 lines
2331 bytes
2331 bytes
Hi,
I hope that this is the right newsgroup to post this problem.
I need to use a class that has many static variables. I've tested it as
a standalone class, and it works. Now I'm trying to put it in a DLL. I use
many DLLs in my project group, and all work as I expect to, but I can't use
static variables from outside the DLL. They seem to have random values.
My code looks like this:
//--------------------------------------------------------------------------
---------------------- CODE STARTS
#ifdef __DLL__
#define DLL_EXP __declspec(dllexport)
#else
#define DLL_EXP __declspec(dllimport)
#endif
class DLL_EXP CParameters
{
protected:
CParameters(CParameters&);
CParametersoperator =(CParameters&);
CParameters();
~CParameters();
static CParameters * parm;
public:
static void InitDefaults();
//camera dependent params
static int VImageMaxX,
VImageMaxYM
VGain;
};
//--------------------------------------------------------------------------
---------------------- CODE ENDS
the parm variable is a Singleton. I build it the first time that
InitDefaults is called, i'm __sure__ that all parameters have been
initialized. Inside the DLL the values seem to be right, but when I try to
use them outside the DLL, they have random values.
Does anyone have any idea to suggest?
Thanks in advance,
Gianstefano Monni
Technical Details
Message-ID:
<3e9a5fdd$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-08!supernews.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,918af439d9321e65,start X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2003-04-14 00:21:07 PST From: "Gianstefano Monni" <gstefano@crs4.it> Newsgroups: borland.public.cppbuilder.nativeapi Subject: static variables of a Class inside a DLL Date: Mon, 14 Apr 2003 09:14:38 +0200 Lines: 45 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 NNTP-Posting-Host: 195.103.60.8 Message-ID: <3e9a5fdd$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1050304477 195.103.60.8 (14 Apr 2003 00:14:37 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-08!supernews.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail