Fortunately, much more complex build functions work fine [...]
Are they also built-in build functions? Because GCC uses a completely different syntax for inline assembler. You can make the syntax more familiar, but see wikipedia .
1 int Convert(double value) 2 { 3 int result; 4 __asm__ __volatile__ ( 5 "fist %0\n\t" 6 : "=m" (result) 7 : "t" (value) 8 ); 9 return result; 10 }
How do i do that. =m indicates that we want the memory operand to save the result (we do not want the register as fist not to work with them). t indicates that the value is being passed at the top of the stack, which also provides the correct cleanup for us.
EDIT:
Another thing to try, assuming gcc with xcode allows the same inline assembler as msvc:
int Convert(double value) { int result; _asm { fld value push eax fistp dword ptr [esp] pop eax mov [result], eax } return result; }
It should also overshadow the warnings about missing return values that you are likely to receive. It just might be that it is more strict to allow you to return values from assembler blocks, write eax than msvc.
source share