Click here to Skip to main content
15,913,486 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralInitializing Static Variables in C++ Libraries Pin
sjcomp1-Oct-03 8:23
sjcomp1-Oct-03 8:23 
GeneralRe: Initializing Static Variables in C++ Libraries Pin
Joaquín M López Muñoz1-Oct-03 9:42
Joaquín M López Muñoz1-Oct-03 9:42 
GeneralRe: Initializing Static Variables in C++ Libraries Pin
sjcomp1-Oct-03 10:00
sjcomp1-Oct-03 10:00 
GeneralRe: Initializing Static Variables in C++ Libraries Pin
Joaquín M López Muñoz1-Oct-03 10:12
Joaquín M López Muñoz1-Oct-03 10:12 
GeneralRe: Initializing Static Variables in C++ Libraries Pin
sjcomp1-Oct-03 10:33
sjcomp1-Oct-03 10:33 
GeneralRe: Initializing Static Variables in C++ Libraries Pin
Joaquín M López Muñoz1-Oct-03 11:28
Joaquín M López Muñoz1-Oct-03 11:28 
GeneralRe: Initializing Static Variables in C++ Libraries Pin
sjcomp1-Oct-03 12:52
sjcomp1-Oct-03 12:52 
GeneralRe: Initializing Static Variables in C++ Libraries Pin
igor19601-Oct-03 10:18
igor19601-Oct-03 10:18 
ACoording to C++ specification:
All static variables are initialized to 0(NULL) by loader before being initialized by CRT.
So, if you can changed your LIB if available and provide check in you constructor like that:
...<br />
class foo<br />
{<br />
 static bool s_initialize;<br />
 static int s_a;<br />
 int m_var;<br />
 foo()<br />
 {<br />
  if (!s_initialized)<br />
  {<br />
     s_a = 1;<br />
     s_initialized = true;<br />
  }<br />
  m_var=s_a;<br />
}<br />
...<br />
int foo::s_initialized = false;<br />
int foo::s_a=1;<br />
...

Or just use (s_a == 0) check if 0 is not possible value...

"...Ability to type is not enough to become a Programmer. Unless you type in VB. But then again you have to type really fast..."
Me
GeneralRe: Initializing Static Variables in C++ Libraries Pin
sjcomp1-Oct-03 10:28
sjcomp1-Oct-03 10:28 
GeneralRe: Initializing Static Variables in C++ Libraries Pin
igor19601-Oct-03 10:52
igor19601-Oct-03 10:52 
GeneralRe: Initializing Static Variables in C++ Libraries Pin
sjcomp1-Oct-03 12:50
sjcomp1-Oct-03 12:50 
GeneralCreatethread into class Pin
jerome_data1-Oct-03 8:21
jerome_data1-Oct-03 8:21 
GeneralRe: Createthread into class Pin
Joaquín M López Muñoz1-Oct-03 9:48
Joaquín M López Muñoz1-Oct-03 9:48 
GeneralFading out a programs window Pin
Anonymous1-Oct-03 6:26
Anonymous1-Oct-03 6:26 
GeneralRe: Fading out a programs window Pin
Ravi Bhavnani1-Oct-03 10:20
professionalRavi Bhavnani1-Oct-03 10:20 
GeneralDll resource problem for experts Pin
YaronNir1-Oct-03 6:06
YaronNir1-Oct-03 6:06 
GeneralRe: Dll resource problem for experts Pin
igor19601-Oct-03 7:57
igor19601-Oct-03 7:57 
GeneralHighlighting Images Pin
Joseph Dempsey1-Oct-03 5:32
Joseph Dempsey1-Oct-03 5:32 
GeneralRe: Highlighting Images Pin
Joaquín M López Muñoz1-Oct-03 10:10
Joaquín M López Muñoz1-Oct-03 10:10 
GeneralRe: Highlighting Images Pin
Joseph Dempsey1-Oct-03 16:35
Joseph Dempsey1-Oct-03 16:35 
GeneralWebBrowser - browse in one window Pin
rrrado1-Oct-03 5:18
rrrado1-Oct-03 5:18 
GeneralRe: WebBrowser - browse in one window Pin
David Crow1-Oct-03 7:10
David Crow1-Oct-03 7:10 
GeneralRe: WebBrowser - browse in one window Pin
rrrado1-Oct-03 21:54
rrrado1-Oct-03 21:54 
GeneralRe: WebBrowser - browse in one window Pin
igor19601-Oct-03 7:59
igor19601-Oct-03 7:59 
GeneralRe: WebBrowser - browse in one window Pin
rrrado1-Oct-03 22:04
rrrado1-Oct-03 22:04 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.