Date: Wed, 15 Oct 1997 13:13:23 +0200 (IST) From: Eli Zaretskii To: Peter Palotas cc: "Salvador Eduardo Tropea (SET)" , djgpp AT delorie DOT com Subject: Re: RHIDE Question. In-Reply-To: <3.0.16.19971014211737.34f75736@hem1.passagen.se> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Precedence: bulk On Tue, 14 Oct 1997, Peter Palotas wrote: > >This was discussed some time ago and nobody was able to show an example (of > >logic code ;-) that really needs a sequence of compilation/link. > >Why do you want to tell an specific order? I only make a similar thing > >when I want to test the compilation of one file without compiling > > the rest first, for this there are an option to compile one file. > > Well, I think I can give an example. I want to compile a file which outputs > a headerfile (.h). And this file is included in some of the .C* files that > I compile. (Compile might be the wrong work, but anyway... I use some AWK > scripts/programs and CPP to generate a headerfile from several others > anyway, and this has to be created *before* any of the other files are > compiled). This should be done by Make. Make will ensure that any target required to produce another target is made first. However, I think I have a case where the link order really is important. This is when one or more of the modules being linked use functions with `__attribute__((constructor))' or ((destructor)). For example, imagine that a program uses Filesystem Extensions to install handlers for some special files, and uses the constructor attribute to make the installation happen before `main' gets called. These functions will be invoked by the startup/exit code in the order they are seen by the linker. And that order might be important, e.g. when one function needs to install itself ahead of others, so it sees the calls first.