2019-02-24 11:31 AM
Hi,
I've been playing around and refactoring a small test app for the STM32F769 DISCO board. The app runs fine and I retest after even the smallest code tweak.
What I'm seeing is that physical position of the function SysTick_Handler within the source code, impacts its run-time behavior!
For example this runs:
whereas this fails:
If I interrupt the failing version, I see this stack trace:
Now I've used C a great deal (Windows and interop with C#) but eased off about three years ago, I'm very new to C++ too. However I've developed compilers for pretty complex languages (compilers written in C in fact) and I've never seen or heard of this kind of sensitivity to the location of functions, I'm not aware of anything in either C or C++ languages that explains this.
...a short time later...
OK it's me, I'm a bozo - the extern "C" directive is required and was being applied or not applied as I moved the code body around! Declaring a prototype and ensuring it has extern "C" fixes it all!
Thx
2019-02-24 12:01 PM
https://stackoverflow.com/questions/1041866/what-is-the-effect-of-extern-c-in-c
xtern "C" void foo(int);
extern "C"
{
void g(char);
int i;
}
Programming in C, this never happened to me.
Maybe there is a conflict in C++ with "weak" and "extern C" for the C++ linker.