public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Sarangdhar, NitinX" <nitinx.sarangdhar@intel.com>
To: "'Alexandre Oliva'" <aoliva@redhat.com>,
	"Sarangdhar, NitinX" <nitinx.sarangdhar@intel.com>
Cc: "'gcc@gcc.gnu.org'" <gcc@gcc.gnu.org>
Subject: RE: C++ Static Variable Initialization
Date: Fri, 17 Aug 2001 13:45:00 -0000	[thread overview]
Message-ID: <19BD7227A489D411AC5200902746200B169F37@orsmsx55.jf.intel.com> (raw)

Thanks for your response. I do not have a main() program. I am creating a
shared library using g++. This shared library gets called from an existing
commercial application hence I do not have control over it.

As I understand the process, g++ emits magic during main() call to
initialize "static const" variables to their defined value. I have seen that
if the variables do not get initialized proeprly specifically if they are of
string type. I have found out that the reason for this is absence of main()
in my program, where these variables are supposed to be initialized.

After reading some reference books, I have found out that there may be a
compiler dependent procedure that I can call to initialize these variable.
Specifically since I am using g++ compiler, what function call can I make to
intialize all my static const string variables properly. 





-----Original Message-----
From: Alexandre Oliva [ mailto:aoliva@redhat.com ]
Sent: Thursday, August 16, 2001 6:28 PM
To: Sarangdhar, NitinX
Cc: 'gcc@gcc.gnu.org'
Subject: Re: C++ Static Variable Initialization


On Aug 14, 2001, "Sarangdhar, NitinX" <nitinx.sarangdhar@intel.com> wrote:

> I have a C++ code with some static declarations. In the absence of main()
is
> there a way to initialize the statics properly? 

What appears to be the problem?  g++ does emit magic to get C++
globals initialized if you link in the gcc run-time object files,
which are implicitly linked in when you use g++ for linking.

-- 
Alexandre Oliva   Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer                  aoliva@{cygnus.com, redhat.com}
CS PhD student at IC-Unicamp        oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist    *Please* write to mailing lists, not to me

             reply	other threads:[~2001-08-17 13:45 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-08-17 13:45 Sarangdhar, NitinX [this message]
  -- strict thread matches above, loose matches on Subject: below --
2001-09-15 17:12 Marcel Ruff
2001-08-17 14:29 Benjamin Kosnik
2001-08-14 16:14 Sarangdhar, NitinX
2001-08-16 18:30 ` Alexandre Oliva

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=19BD7227A489D411AC5200902746200B169F37@orsmsx55.jf.intel.com \
    --to=nitinx.sarangdhar@intel.com \
    --cc=aoliva@redhat.com \
    --cc=gcc@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).