Xref: news2.mv.net comp.os.msdos.djgpp:2103 From: fnunez AT cs DOT uct DOT ac DOT za (Fabian Nunez) Newsgroups: comp.os.msdos.djgpp Subject: Re: Optimization causes error? Date: 23 Mar 1996 09:54:54 GMT Organization: University of Cape Town Lines: 36 Message-ID: <4j0hpe$er2@groa.uct.ac.za> References: <31531424 DOT 2096 AT jeffnet DOT org> NNTP-Posting-Host: dione.cs.uct.ac.za To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp In <31531424 DOT 2096 AT jeffnet DOT org> Chris Dial writes: >I have a problem with DJGPP 2.0. When I turn all optimizations on it >gives me the following error at compile time: >c:/djgpp/tmp\cciaaaaa: Assembler messages: >c:/djgpp/tmp\cciaaaaa:697: Fatal error:Symbol MyLoop already defined. >It does _not_ give me these messages if I only use partial optimization >or none at all (eg: -O3 causes the error, -O2 does not) >asm( >" MyLoop: > decl %ecx > jnz MyLoop" >); This happens because the -O3 option goes berserk, inlining everything it can. Unfortunately the inline asm does not touch the labels you provide, so if you call your asm routine more than once in your code there is more than one copy of your asm routine in the asm file generated (compile with -S to see it). The solution is to simply write your asm function in a different source file to the one it is used in (maybe asmstuff.cc). In this way the compiler cannot inline your asm (since it ends up in a different .o file) and your problem is solved. (maybe this should be in the FAQ, it's kindof an annoying feature of GCC) >-Chris Dial -- Fabian Nunez, Bsc(hons) student, University of Cape Town email:fnunez AT cs DOT uct DOT ac DOT za web:http//www.cs.uct.ac.za/~fnunez --------------------------------------------------------------- The Holy See is NOT the Vatican's Computer Science Department!