asm inside .cpp file

OP #1172856
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
Moderator
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

Reply

A question of your own? This thread is over 19 years old. Ask it in a thread of its own – more people read along there, and it gets answered more often and sooner.

Start a new thread

A fix, an addition or feedback on this thread? Then reply here.

Formatting
  • [c]C-Code[/c]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]
  • [[Title]] – link to an article
  • Link to another post: right-click its post ID (#8078628), copy the address, paste it into the text

More about formatting

Post long source code as an attachment, not in the text.

Already registered? Log in

Not shown to anyone. We send you a link; your post appears once you confirm it there.

By submitting you create a free account and accept the terms of use.