I've got yet another error trying to compile with Apple GCC 4.2.1 using the -fasm-blocks argument (which enables Intel style assembly syntax) inline assembly code which worked in MSVC : block assembly operand not recognized , label 'LASM$TYPE' used but not defined :
typedef struct _MyStruct
{
int data;
//...
}MyStruct;
void testAsm()
{
MyStruct *pMyStruct = new MyStruct(); // Please not that I create an instance of MyStruct here only for the sake of simplicity
_asm
{
mov edi, pMyStruct
add edi, TYPE MyStruct // error: block assembly operand not recognized. label 'LASM$TYPE' used but not defined
//...
};
delete pMyStruct;
}
How can I fix this problem?
TYPE
is an MSVC-specific asm
keyword. Here it just means sizeof
. I tried to find some gcc asm-block documentation on the web, but I gave up after ten minutes. Try
add edi,sizeof(MyStruct)
and variants. I don't have an Apple, so I can't try it out for you.
Updated to answer question in comment: Try this:
add edi,__offsetof(MyStruct,MyMember)
If it doesn't work, see "Using the GNU Compiler Collection" for documentation.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.