cancel
Showing results for 
Search instead for 
Did you mean: 

App fails when source is changed in a trivial way.

Korporal
Senior

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:

0690X000006DoIyQAK.jpg

whereas this fails:

0690X000006DoJ8QAK.jpg

If I interrupt the failing version, I see this stack trace:

0690X000006DoJDQA0.jpg

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

1 REPLY 1
S.Ma
Principal

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.