EmbDev.net

Forum: ARM programming with GCC/GNU tools asm inside .cpp file


von Dustin S. (dbrazeau)


Rate this post
useful
not useful
I have a .cpp file that has some asm in it, e.g. asm(" asm source line
");, and in the "asm source line" I'm trying to use a symbol that is
defined/equ in a .inc file.  When I try to compile the cpp file it says
that the symbol is undefined.  How do I include an asm .inc file when
the asm code is enbedded in a .cpp file.

Thanks
dbrazeau

von Martin T. (mthomas) (Moderator)


Rate this post
useful
not useful
Dustin Sr wrote:
> I have a .cpp file that has some asm in it, e.g. asm(" asm source line
> ");, and in the "asm source line" I'm trying to use a symbol that is
> defined/equ in a .inc file.  When I try to compile the cpp file it says
> that the symbol is undefined.  How do I include an asm .inc file when
> the asm code is enbedded in a .cpp file.

This might be a name-mangling/name-decoration issue. But I have not
tested inline-assembler and C++ with the GNU arm-cross-toolchain so far
and at least for me it's difficult to help without a test-example to
reproduce the issue. Please create a minimal but complete example
(source, linker-script, makefile) and attach it to a message to this
forum. Maybe just an extern "c" for the "symbol" will do. As a
workaround you can create c-source (not C++) with a functions that
"wraps" the inline-assembler, use extern "c" to include the function and
call it from the C++-function/method. Another workaround would be a
"pure" assembler-function.

Martin Thomas

Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.