Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Message-ID: <3F333660.7090609@lynx-technik.com> Date: Fri, 08 Aug 2003 07:34:24 +0200 From: "H. Henning Schmidt" Organization: LYNX Technik AG User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.0.1) Gecko/20020823 Netscape/7.0 X-Accept-Language: en-us, en MIME-Version: 1.0 To: cygwin AT cygwin DOT com, alan AT vacooley DOT com Subject: RE: gcc - static pointer initialization problem Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit This is pretty OT for this list. It's a plain "C" language issue. You are creating two instances of type , all named . One is instanciated and initialized as you expect in static_function_ptr_def.c. But this instance is , 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/