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

 Author: Dustin Sr (dbrazeau) Posted on: 2007-09-21 01:31

Rate this post
 0 ▲ 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

 Author: Martin Thomas (mthomas) (Moderator) Posted on: 2007-09-21 16:18

Rate this post
 0 ▲ 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

• $formula (LaTeX syntax)$