I try to use atomics in Cin FreeBSD 10.1 Release with clang 3.6.1, however, when I try to compile a program using the ATOMIC_FLAG_INITin variable atomic_flagin struct, I get error: expected expression.
Here is the program I'm trying to compile.
#include <stdio.h>
#include <stdatomic.h>
struct map
{
atomic_flag flag;
};
int main(void)
{
struct map *m = malloc(sizeof(struct map));
m->flag = ATOMIC_FLAG_INIT;
free(m);
return 0;
}
I can use atomic_flagout structs, as in the example below, but not in structs, since you use atomic variables in C structs?
#include <stdio.h>
#include <stdatomic.h>
int main(void)
{
atomic_flag flag = ATOMIC_FLAG_INIT;
return 0;
}
source
share