Date: Sat, 8 Apr 2000 05:55:20 +0600 (LKT) From: Kalum Somaratna aka Grendel X-Sender: root AT darkstar DOT grendel DOT net To: djgpp AT delorie DOT com Subject: Re: about compiler or linker In-Reply-To: <3A4F7E81.C767B4B@caresystems.com.au> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Reply-To: djgpp AT delorie DOT com Errors-To: nobody AT delorie DOT com X-Mailing-List: djgpp AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk On Mon, 1 Jan 2001, leon wrote: > > also about inline methods - if one declares a method inline - how does > the compiler know - where to get source code from (since usually the > client of a class only includes header files and it is possible to > define inline method in source files). Well the compiler knows where to get the inlined function from because the inlined function should be defined in a header file. So when the header file is included by a source (.cpp) file which references the inlined function the compiler will substitute the function body (which it allready knows about as it read it in the header file) whereever it is necessary in the source file. //example header file foo.h inline void test() { //your code here } now there is a fill called foo.c // file foo.c #include "foo.h" //now the compiler has read the foo.h and is aware of the inlined test function void main() { test(); //the compiler will replace this with the inlined function //but if i the inlined function was not in the header file then the //compiler would never know... } > Would then the linker try and introduce source code to objects when > linking or what? AFAIK inline routines cannot be implemented in a source file and then refrenced in another source file. Inline functions can be in the source file, but then they if they are to be inlined properly then they have to be referenced in the _same_ source file.. Grendel Hi, I'm a signature virus. plz set me as your signature and help me spread :)