Atomic operations with <stdatomic.h> in IDF?
Posted: Thu Jan 05, 2017 9:10 am
Hi!
I'm trying to write an ISR for a quadrature encoder. My function needs to xor a global variable and increments a global counter. I figured the correct way to do that would be by using atomic operations defined in <stdatomic.h>. However, when I include this header file, I get a lot of error messages (see below).
What's the recommended way to perform atomic operations if we can't use functions like atomic_fetch_xor(), atomic_fetch_add() ?
I'm trying to write an ISR for a quadrature encoder. My function needs to xor a global variable and increments a global counter. I figured the correct way to do that would be by using atomic operations defined in <stdatomic.h>. However, when I include this header file, I get a lot of error messages (see below).
What's the recommended way to perform atomic operations if we can't use functions like atomic_fetch_xor(), atomic_fetch_add() ?
Code: Select all
In file included from /Users/jakob/Documents/esp32/idf/esp-idf/components/newlib/include/stdatomic.h:33:0,
from /Users/jakob/Documents/esp32/idf/romibot/main/./odometry.c:1:
/Users/jakob/Documents/esp32/idf/esp-idf/components/newlib/include/stdatomic.h:204:17: error: expected specifier-qualifier-list before 'int_least8_t'
typedef _Atomic(int_least8_t) atomic_int_least8_t;
^
/Users/jakob/Documents/esp32/idf/esp-idf/components/newlib/include/sys/cdefs.h:296:30: note: in definition of macro '_Atomic'
#define _Atomic(T) struct { T volatile __val; }
^
/Users/jakob/Documents/esp32/idf/esp-idf/components/newlib/include/stdatomic.h:205:17: error: expected specifier-qualifier-list before 'uint_least8_t'
typedef _Atomic(uint_least8_t) atomic_uint_least8_t;
^
( ... and so on ...)