Skip to main content
Associate
September 24, 2024
Solved

CubeIDE CPP project and Assembly Include

  • September 24, 2024
  • 1 reply
  • 963 views

Hello,

I have problem with including assembly code into my C++ project.

Include section of main.cpp:

#include "asm_math_wk.h"

asm_math_wk.h file:

#ifndef INC_ASM_MATH_WK_H_
#define INC_ASM_MATH_WK_H_

extern void megawkurw(uint32_t test);

#endif /* INC_ASM_MATH_WK_H_ */

 

asm_math_wk.s file:

.syntax unified

.global megawkurw
.type megawkurw, %function

megawkurw:
.fnstart
movs R1, R0
bx LR
.fnend

 

When I call my assembly function:

megawkurw(999);

 

I get build error:

main.cpp: undefined reference to 'megawkurw(unsigned long)'

 

This problem occurs only in .cpp, when I include same assembly code into the .c project, everything compiles fine.

 

Best Regards

Best answer by Tesla DeLorean

extern "C" void megawkurw(uint32_t test); // address name mangling..

1 reply

Tesla DeLorean
Tesla DeLoreanBest answer
Guru
September 24, 2024

extern "C" void megawkurw(uint32_t test); // address name mangling..

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
WikteAuthor
Associate
September 24, 2024

It compiles fine.

You are great, thank you!

BR,

Wikte