From dev-return-7595-apmail-stdcxx-dev-archive=stdcxx.apache.org@stdcxx.apache.org Thu May 08 04:23:36 2008 Return-Path: Delivered-To: apmail-stdcxx-dev-archive@www.apache.org Received: (qmail 91478 invoked from network); 8 May 2008 04:23:36 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 8 May 2008 04:23:36 -0000 Received: (qmail 9401 invoked by uid 500); 8 May 2008 04:23:38 -0000 Delivered-To: apmail-stdcxx-dev-archive@stdcxx.apache.org Received: (qmail 9385 invoked by uid 500); 8 May 2008 04:23:38 -0000 Mailing-List: contact dev-help@stdcxx.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@stdcxx.apache.org Delivered-To: mailing list dev@stdcxx.apache.org Received: (qmail 9372 invoked by uid 99); 8 May 2008 04:23:38 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 07 May 2008 21:23:37 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of msebor@gmail.com designates 209.85.146.180 as permitted sender) Received: from [209.85.146.180] (HELO wa-out-1112.google.com) (209.85.146.180) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 08 May 2008 04:22:51 +0000 Received: by wa-out-1112.google.com with SMTP id v27so1089728wah.21 for ; Wed, 07 May 2008 21:23:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:organization:user-agent:mime-version:to:subject:references:in-reply-to:content-type:content-transfer-encoding:sender; bh=m4UHMyjgCWcUkIW+aOFPv6XFOLJCs1Fuj8ON0V9Y1ys=; b=jgGwqTkQno/W6rLdnxkKHLYldIKZA0E/4HkiMN5JmfF46JA+yjU86hUjnwq4KvCp4XE1Mk8jBQZMIaJ7UR05eowYiIJbLYzc3TeoWdc2ZIj8nDltzb7UvjjMdI7PeeEcvDzbSZabGIwPvrAYYDmwM416mnnRA8hfpb0ZIrQzOPI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:organization:user-agent:mime-version:to:subject:references:in-reply-to:content-type:content-transfer-encoding:sender; b=Sb//gJbnvpY6wAaJh/4yNyiyf4o1RmNvMXGiQ0/XKpwh/PK8RRCpZzVZCc+M3h0ABLKvcHO5fuO8PC3GOeqazwACTHBhteUxk37ZYa4FEDn/cj9T7OcTmOjJzmjILZwmVbwKNcw4+fC/HkxyhvqBIBy596m/5cdcd+VKX0SaqEo= Received: by 10.115.75.1 with SMTP id c1mr2654413wal.114.1210220585944; Wed, 07 May 2008 21:23:05 -0700 (PDT) Received: from localhost.localdomain ( [71.229.200.170]) by mx.google.com with ESMTPS id t1sm5734951poh.9.2008.05.07.21.23.05 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 07 May 2008 21:23:05 -0700 (PDT) Message-ID: <48228028.4050806@roguewave.com> Date: Wed, 07 May 2008 22:23:04 -0600 From: Martin Sebor Organization: Rogue Wave Software, Inc. User-Agent: Thunderbird 2.0.0.12 (X11/20080226) MIME-Version: 1.0 To: dev@stdcxx.apache.org Subject: Re: ios_base::Init::Init (); References: <17111782.post@talk.nabble.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Sender: Martin Sebor X-Virus-Checked: Checked by ClamAV on apache.org Travis Vitek wrote: > > >> pegasus2000 wrote: >> >> I've compiled with success the first version >> of NanoCPP (STDCXX for Nanodesktop). >> >> So, when I enter this program: >> >> #include >> >> #include >> >> int main() >> { >> ndInitSystem (); >> using namespace std; >> >> ios_base::Init::Init (); >> >> cout << "Hello World!"; >> return 0; >> } >> >> I obtain the "Hello world" on the >> screen of the PSP. >> >> But, if I remove the string: >> >> ios_base::Init::Init (); >> >> the system crashes at startup. Is it >> a normal behaviour or there's some >> option in config.h that I must enable >> in order to autoinit any object ? > > ios_base::Init::Init() is the constructor for the type ios_base::Init. > You probably shouldn't be calling it directly, I'm almost surprised that > it compiles. At the very least you should be using it by creating an > object of that type so that the destructor is called. > > You should not normally have to do this. It should be done automatically > for you at dynamic initialization time. Right. On most platforms it should happen when the header is #included. But calling Init() directly is perfectly fine and has the same effect as #including . I was hoping we had a test for this (e.g., 27.objects.cpp) but it doesn't look like we do. We should add one... > > From the looks of it, I'd guess that _RWSTD_NO_STATIC_IOSTREAM_INIT is > getting defined somewhere. I peeked at my config.h and the config tests > and I don't see that macro anywhere. Do you define this macro somewhere? To add to what Travis said: the area of iostream initialization is tricky. We do it one of three ways, depending on the OS and compiler. For gcc, std::cin, std::cout, std::cerr, and std::clog (and their wide equivalents) are declared as references to POD objects defined in iostream.cpp and lazily initialized in the first call to ios::Init::Init(). The header defines a static object on type ios::Init whose ctor is responsible for this initialization. From your description it sounds as though this object's ctor doesn't run before the inserter is entered in your program. You need to figure out why :) Let us know how it goes. Martin