X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f X-Recipient: djgpp AT delorie DOT com Date: Tue, 25 Oct 2011 18:30:45 +0200 From: Eli Zaretskii Subject: Re: _rdtsc(void) inline function in time.h - cause problem with multiple definition during linking In-reply-to: <4ce51722-c2fd-4fe0-8cb9-ebae498c3271@r1g2000yqm.googlegroups.com> X-012-Sender: halo1 AT inter DOT net DOT il To: djgpp AT delorie DOT com Message-id: <83k47tc9u2.fsf@gnu.org> References: <4ce51722-c2fd-4fe0-8cb9-ebae498c3271 AT r1g2000yqm DOT googlegroups DOT com> 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 > From: RayeR > Date: Tue, 25 Oct 2011 04:02:09 -0700 (PDT) > > during compiling large sources I run into troubles with multiple > _rdtsc(void) definition during linking. The problem is caused when in > 1st stage is compiled a library that includes time.h and then in 2nd > stage is compiled main app that also includes time.h Because there is > _rdtsc() code already in library linker got confused what to use. > > Do you think it should be fixed DJGPP time.h header to redefine > > extern __inline__ unsigned long long > _rdtsc(void) > { > unsigned long long result; > __asm__ __volatile__ ("rdtsc" : "=A"(result) ); > return result; > } > > to static? Can you show the error messages you get? It is strange that you should get any errors at all: an inline function is like a macro, it disappears without a trace in the compiled object code, so the linker should not complain, because there's no symbol corresponding to the function for it to see any multiple definitions. There simply should not be any definition at all. Did you perhaps disable inlining, or compiled with some headers that define away __inline__?