Christopher Coale wrote:
> gsronline wrote:
>> Hi
>>
>> I am converting an application from VS6 to VS7 (vs2003). There are some
>> code which are asm. When I am trying to compile the files, its throwing
>> errors. please let me know how to tell the compiler to treat them as ASM
>>
>> eg:
>> #define BREAK asm __volatile__ (" break ");
>>
>> //compiler throws this error:
>> error C2061: syntax error : identifier '__volatile__'
>>
>> thanks
>> Rajesh
>>
>>
> Visual C++ doesn't use the AT&T assembler that GCC uses. When you inline
> ASM in Visual C++, it is using MASM, and you have to type the "__asm"
> keyword.
>
> #define BREAK __asm instruction;
I'm pretty certain there is no MASM interaction with inline assembler.
Especially since I have a bunch of it here on my computer and have not
seen MASM invoked for any of it. I also have some .asm files in at
least one third-party library for which MASM _IS_ invoked.
Anyway, nitpicks aside, the PROPER way to declare inline assembler in VC++:
_asm {
...Yes, it is _asm, not __asm...
...Intel assembler instructions go here...for example...
push eax
mov eax, SomeVariable
inc eax
mov dword ptr SomeVariable2, eax
pop eax
}
So your #define could be changed to this (assuming 'break' is valid
assembler):
#define BREAK _asm { break }
Or, perhaps a better approach:
#define BREAK DebugBreak()
(But the debugger, ironically, doesn't really react well to the
DebugBreak() API call).
--
Thomas Hruska
CubicleSoft President
Ph: 517-803-4197
*NEW* MyTaskFocus 1.1
Get on task. Stay on task.
http://www.CubicleSoft.com/MyTaskFocus/