Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 8082

General • Re: Optimiser behaviour (C/C++)

$
0
0
Yes. what you describe is perfectly normal optimizer behavior - and therefore not annoying, but desirable.

The "volatile" type qualifier exists for a reason. Oversimplified, every variable that can may change spontaneously (e.g., because it is written from within an interrupt handler or callback, or because it actually is hardware register) must be declared volatile.

Code:

static volatile uint64_t last_time = 0;static volatile uint64_t time = 0;static volatile bool edge = false;

Statistics: Posted by czietz — Tue Jun 03, 2025 5:37 am



Viewing all articles
Browse latest Browse all 8082

Trending Articles