Get errors while using setjmp & longjmp

Hello!
What Im trying to make is a car that can be controlled in 2 ways: joystick or auto. Joystickworks fine, auto I cant test right now, but thats not the topic. I want to interrupt my auto mode code execution using my joystick. After some research, I found setjmp & longjmp. I couldnt find any good tutorial, so I get errors. I know my solution to this isn`t good but I have deadline this Friday. Thanks in advance!
Code is on GitHub http://https://github.com/vitaliy172/metalDetectorCar-/blob/vitaliy172-patch-2/Patsiuk/Patsiuk.ino

C:\Users\Admin\AppData\Local\Temp\arduino_modified_sketch_485711\sketch_dec06b.ino: In function 'void setup()':
C:\Users\Admin\AppData\Local\Temp\arduino_modified_sketch_485711\sketch_dec06b.ino:139:13: warning: unused variable 'buf' [-Wunused-variable]
     jmp_buf buf;
             ^~~
C:\Users\Admin\AppData\Local\Temp\arduino_modified_sketch_485711\sketch_dec06b.ino: In function 'void loop()':
sketch_dec06b:143:12: error: 'buf' was not declared in this scope
     setjmp(buf);
            ^~~
C:\Users\Admin\AppData\Local\Temp\arduino_modified_sketch_485711\sketch_dec06b.ino: In function 'void recieveData()':
sketch_dec06b:229:13: error: 'buf' was not declared in this scope
     longjmp(buf, 1);
             ^~~

Your link to your code does not work for me.

If you want help here, post your code here. Read the how get the most out of this forum sticky to see how to properly post code. Remove useless white space and format the code with the IDE autoformat tool (crtl-t or Tools, Auto Format) before posting code. If the code is too large to post it can be attached.

The only meaningful declaration of a jump buffer in you code is this

jmp_buf startLoop;

which you never use.

“buf” is not defined where you use it, and it doesn’t look at a glance like you’ve caught the actual idea of set/long jump anyway.

Find some simple examples and study them.

Or, as will certainly be advise here by others, solve this without set/long jump, something many programmers have never heard of or found a use for, double that for this kind of programming problem.

You don’t need it, it does work but you have to use it just so.

a7