Download

variables with UPROPERTY attribute cannot be decleared as "volatile"?

Hi people:
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category=Gameplay)
bool volatile IsLeft;

this piece of code cannot pass compilation, it said that
Unrecognized type ‘volatile’

but without setting it to UPROPERTY, it will pass the compilation.
Is there anyway to let UPROPERTY marked variable thread safe?

Thanks
Walter.

The volatile keyword doesn’t make your variable thread safe at all. You need to use other mechanisms to do that. volatile will only assure that if some hardware wrote to that memory that you will see that change when you read the variable.

I kept the read and write operation be atomic so currently no need to add locks, but how to add volatile keyword?

btw the volatile is place before the bool, I wrongly pasted it.