Search code examples
cassemblyvisual-c++-2010-express

How do I resolve error C2059: syntax error : '__asm' in Visual C++ 2010 Express


The file in which there is inline asm code is of the form xyz.c I'm using Visual C++ 2010 Express IDE. I get the error mentioned in the title. Any help is appreciated! Thanks!

My code roughly looks like this.

#include "xyz.h"

/*
; Multi-line comments
;
*/

__asm{
    Assembly code
}
 /*
; Multi-line comments
;
*/
.
.
.

__asm{
    Assembly code
}
 /*
; Multi-line comments
;
*/

__asm{
    Assembly code
}

Solution

  • You can not put the asm code (or any other code) directly into the global scope. You have to put it inside a function.

    void f()
    {
        __asm {
            Some code
        }
    }