473,387 Members | 1,542 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Global object initialization

I read in the book "Inside C++ Object Model" that for every global
object, the compiler generates an _sti function, which are then called
in sequence before the first user-defined statement of main.

I understand that this is compiler dependent.
But for curiosity, why doesn't the compiler directly call the
construcotors in main(instead of defining the _sti function and then
calling the function)

--Paresh

Sep 20 '05 #1
2 2715
Ian
pa********@gmail.com wrote:
I read in the book "Inside C++ Object Model" that for every global
object, the compiler generates an _sti function, which are then called
in sequence before the first user-defined statement of main.

I understand that this is compiler dependent.
But for curiosity, why doesn't the compiler directly call the
construcotors in main(instead of defining the _sti function and then
calling the function)

What happens if you don't have a main() ?

Ian
Sep 21 '05 #2
> I read in the book "Inside C++ Object Model" that for every global
object, the compiler generates an _sti function, which are then called
in sequence before the first user-defined statement of main.

I understand that this is compiler dependent.
But for curiosity, why doesn't the compiler directly call the
construcotors in main(instead of defining the _sti function and then
calling the function)

--Paresh

Do you mean with visible code in the main function? It doesn't make sense
for code to be compiler generated and editable as well.

Fraser.
Sep 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Phil Lamey | last post by:
Hi All, I have the following code but for some reason I cannot get the Session_OnEnd event to fire. I am trying to limit the amount of connections a browser session can have. Where the...
4
by: Cheng Mo | last post by:
I know global varaibles should always be avoided. I asked this question just for deep insight about C++. If global variables are distributed among different source code files, what's the...
4
by: ypjofficial | last post by:
Pls look at this code ////////////////////start/////////// class a { public: a(){ cout<<"inside constructor of a"<<endl; } int b()
8
by: lawrence | last post by:
I'm learning Javascript. I downloaded a script for study. Please tell me how the variable "loop" can have scope in the first function when it is altered in the second function? It is not defined...
4
by: Aniruddha | last post by:
I want to initialize an array of function pointers (global) If I do it like: /* definition of foo_1, foo_2, foo_3 all return void and take no args */ void (* foo) (); foo = foo_1 ; foo = foo_2...
3
by: Rahul Gandhi | last post by:
Hi, Which one preferable with respect to code size of the executable Un-initialised global variables or initialised global variables regards Rahul
0
by: Tim::.. | last post by:
Hi, Can someone please tell me why I get this error when I try to build my ASP.NET application??? Could not load type 'CPNNet.Global'. Line 1: <%@ Application Codebehind="Global.asax.vb"...
1
weaknessforcats
by: weaknessforcats | last post by:
C++: The Case Against Global Variables Summary This article explores the negative ramifications of using global variables. The use of global variables is such a problem that C++ architects have...
4
by: subramanian100in | last post by:
Suppose I have #include <cstdlib> #include <iostream> using namespace std; class Test { public:
5
by: kiryazev | last post by:
Hello. Given the code below does C++ Standard guarantee that the function my_init() will be called before main()? struct A { A() { my_init(); } };
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.