Compiler Error in inline Assembly error:- C2400: inline assembler syntax error in 'second operand'; found 'newline'
c, compiler-errors, visual-c++
Solution
See here: http://msdn.microsoft.com/en-US/library/wxh0awwe%28v=vs.80%29.aspx
Specifically
The LENGTH, SIZE, and TYPE operators have a limited meaning in inline assembly. They cannot be used at all with the DUP operator (because you cannot define data with MASM directives or operators). But you can use them to find the size of C or C++ variables or types:
Problem
I was testing some C code and came across this strange compiler error The following code would not compile ``` #include<stdio.h> void main() { int length=6; __asm { mov eax,length } } ``` Visual Studio reports the following error ``` test.c(7) : error C2400: inline assembler syntax error in 'second operand'; found 'newline' ``` However, I noticed if I changed the name of the variable to something else say `lengths` then everything was fine, the following code compiles without any difficulty ``` #include<stdio.h> void main() { int lengths=6; __asm { mov eax,lengths } } ``` I tried with other compilers such as Digital Mars and Intel Compiler, but everywhere the first code cannot be compiled. What can be the issue ? Is there another definition for `length` elsewhere. I would also like to add that this is a single file, not a project so there cannot be any multiple declarations.