C++ constructors

Bill Randle billr@exgate.tek.com
Wed May 16 12:20:00 GMT 2001


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



More information about the crossgcc mailing list