Declaring it volatile
Posted Aug 7, 2012 15:57 UTC (Tue) by
PaulMcKenney (subscriber, #9624)
In reply to:
Declaring it volatile by nybble41
Parent article:
ACCESS_ONCE()
I am using gcc 4.6.1, and the following emits a compiler error complaining that an lvalue is needed:
#include <stdio.h>
#define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x))
int q = 3;
int main(int argc, char *argv[])
{
int i = argc;
i = ACCESS_ONCE(({ printk("foo"); q; }));
printk("i = %d\n", i);
}
(
Log in to post comments)