delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/11/25/21:00:32

From: Philosopher DOT bbs AT cszone DOT cc DOT ntu DOT edu DOT tw (色不異空|空不異色)
Newsgroups: comp.os.msdos.djgpp
Subject: call constructors for global objects?
Date: 26 Nov 1998 01:43:15 GMT
Organization: 程式設計樂園(CSZone)
Lines: 28
Message-ID: <3RciX4$Q4x@cszone.cc.ntu.edu.tw>
NNTP-Posting-Host: cszone.cc.ntu.edu.tw
X-Filename: n.djgpp/M.912044596.A
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

        How can a C++ program which has its own start-up code invokes

        the constructos for global objects?

        I found the following code which may be helpful; however,

        the symbol __CTOR_LIST__ will not be defined by g++?

#define DO_GLOBAL_CTORS_BODY                                            \
do {                                                                    \
  unsigned long nptrs = (unsigned long) __CTOR_LIST__[0];               \
  unsigned i;                                                           \
  if (nptrs == -1)                                                      \
    for (nptrs = 0; __CTOR_LIST__[nptrs + 1] != 0; nptrs++);            \
  for (i = nptrs; i >= 1; i--)                                          \
    __CTOR_LIST__[i] ();
} while (0)
#endif

--
  這是一個專門討論 programming 和 computer science 的 BBS
  這裡有人工智慧,類神經網路,即時作業系統,各式Windows programming的專版
  在 cszone.cc.ntu.edu.tw , login:bbs , port 3001~3005
  期待你的加入, 豐富這裡的園地

--
※ Origin: 程式設計樂園 ◆ From: titan.ee.ntu.edu.tw

- Raw text -


  webmaster     delorie software   privacy  
  Copyright � 2026   by DJ Delorie     Updated Sep 20 2026