From owner-freebsd-hackers Thu Jan 15 22:52:43 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id WAA03960 for hackers-outgoing; Thu, 15 Jan 1998 22:52:43 -0800 (PST) (envelope-from owner-freebsd-hackers@FreeBSD.ORG) Received: from wcc.wcc.net (wcc.wcc.net [208.6.232.10]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id WAA03942 for ; Thu, 15 Jan 1998 22:52:38 -0800 (PST) (envelope-from piquan@wcc.wcc.net) Received: from detlev.UUCP (ppp110.wcc.net [208.6.232.110]) by wcc.wcc.net (8.8.7/8.8.7) with ESMTP id AAA23734 for ; Fri, 16 Jan 1998 00:49:27 -0600 (CST) Received: (from joelh@localhost) by detlev.UUCP (8.8.8/8.8.7) id AAA03638; Fri, 16 Jan 1998 00:49:36 -0600 (CST) (envelope-from joelh) Date: Fri, 16 Jan 1998 00:49:36 -0600 (CST) Message-Id: <199801160649.AAA03638@detlev.UUCP> To: atrens@nortel.ca CC: hackers@FreeBSD.ORG In-reply-to: <199801160256.VAA18321@mescaline.gnu.org> (atrens@nortel.ca) Subject: Re: sharable static arrays? From: Joel Ray Holveck Reply-to: joelh@gnu.org References: <199801160256.VAA18321@mescaline.gnu.org> Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk > Therefore, > const char foob[10] = "0123456789"; > will use 10 bytes ( all in text ) , and > char fooba[10] = "0123456789"; > will use 20 bytes ( ten in text, ten in data ). It's that simple. ;) I'm sorry, I must be misunderstanding something. I thought that in the latter case, the variable would be stored in data, period. If fooba[] was in BSS, I can see the need to have the text copy, but why if it's in the executable's data segment? How could I experiment with this? And, based on what you're saying, when does the initializer get copied? By crt0, in start? Somewhere I've got something in the back of my mind telling me that although the initializer for char*x will be stored in text, an initialized char x[10] will be stored entirely in data. If this is mistaken, please let me know. > Now, what's interesting is that > char foobar[10] = " "; > will *also* use 20 bytes - the compiler will pad the initializer with > zeroes. I am familiar with the phenomenon. I'll use it to set defaults for options: char tmp_path[PATH_MAX] = "/tmp"; Thanks for your patience, joelh -- Joel Ray Holveck - joelh@gnu.org - http://www.wp.com/piquan Fourth law of programming: Anything that can go wrong wi sendmail: segmentation violation - core dumped