Date: Fri, 9 Jan 1998 16:21:00 -0800 (PST) Message-Id: <199801100021.QAA00831@adit.ap.net> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" To: =?iso-8859-1?Q?=22Jordi_P=E9rez=22?= , DJGPP From: Nate Eldredge Subject: Re: Error compiling with inline ASM Content-Transfer-Encoding: 8bit Precedence: bulk At 05:10 1/9/1998 +0000, Jordi Pérez wrote: >I have downloaded a GIF loader/saver for Allegro 3.0, but when i try to >compile it (I have followed the instructions of the Readme file), it >showed me the next error message: > > 650: Fatal error: Symbol csb_loop already defined > >I've found this symbol in the next function: > >void clear_speed_buffer(short *speed_buffer) >{ > // clear speed buffer to -1 > __asm__("csb_loop:\n" > "movl %%ecx, (%%eax)\n" > "addl %%edx, %%eax\n" > "decl %%ebx\n" > "jne csb_loop\n" > : > : "a" (speed_buffer), "b" (256 * 4096 / 2), "c" (-1), "d" (4) > : "memory"); >} > >but i don't find any error. I've tried to change csb_loop with another >name, but the message continues. If anyone knows what i'm doing wrong >please reply me. Let me guess: You compile with -O3. This lets the compiler inline this function which means it can appear multiple times. Since a normal label is being used, the multiple occurences conflict. The solution is to use GAS's local labels, which should look something like this: 0: /* ... */ jne 0b See the info node "as" "Symbols" "Symbol Names" for more information about local labels. Incidentally, be advised that this function is also suboptimal and buggy. Using the `rep; stosl' instructions would be more efficient, and they don't tell the compiler that they clobber the appropriate registers, which can lead to bad code. Perhaps you should look for some different code. Nate Eldredge eldredge AT ap DOT net