This is the mail archive of the crossgcc@sources.redhat.com mailing list for the crossgcc project.

See the CrossGCC FAQ for lots more information.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: C++ constructors


On May 16,  4:07pm, Joćo Cadamuro Junior wrote:
} Subject: C++ constructors
[snip]
} Under gcc-2.95.2 the execution order of constructors is the linkage
} order. The first file linked will construct their objects first.
}
} Under gcc-2.95.3, the behavior is the opposite. The last linked archive
} will construct their objects first.
}
} Since I want to have a c++ code to be compiled correctly independent of
} the compiler version, someone knows what can I do to force some order to
} constructors under G++?

The way I've done it in the past is to put ALL the global objects in
one C++ file, then compile and link the file with the other files.
The order the constructors are called will be rthe order the
objects appear in the file. This way, you don't have to depend
on link order.

	-Bill Randle
	Tektronix, Inc.
	billr@exgate.tek.com

------
Want more information?  See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/
Want to unsubscribe? Send a note to crossgcc-unsubscribe@sourceware.cygnus.com

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]