Subject: RE: gcc - static pointer initialization problem
From: "H. Henning Schmidt" <[email-masked]>
To: [email-masked], [email-masked]
Date: Fri, 08 Aug 2003 07:34:24 +0200

This is pretty OT for this list.  It's a plain "C" language issue.

You are creating two instances of type <funcPtrStructDef>, all named 
<funcPtrStruct>.
One is instanciated and initialized as you expect in 
static_function_ptr_def.c. But this instance is <static>, so it cannot 
be used from another module (i.e. from static_function_ptr.c)
Another instance is created and initialized to NULL in 
static_function_ptr.c, instance created in static_function_ptr_def.h 
line 11. This is the one that you are using at runtime. It is NULL and 
it has to be.

Statics are initialized to all zero's, unless explicitly initialized 
otherwise. That is correct, and that is what is happening here.
Instantiating a variable in a header file is hardly ever a good idea .. 
it will usually be instantiated more than once in the runtime.
Static members are not accessible by other modules, so your example 
can't work the way you expect it.

HTH
;Henning

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/