delorie.com/archives/browse.cgi | search |
Mailing-List: | contact cygwin-help AT cygwin DOT com; run by ezmlm |
List-Subscribe: | <mailto:cygwin-subscribe AT cygwin DOT com> |
List-Archive: | <http://sources.redhat.com/ml/cygwin/> |
List-Post: | <mailto:cygwin AT cygwin DOT com> |
List-Help: | <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs> |
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" <Henning DOT Schmidt AT lynx-technik DOT com> |
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 |
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/
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |