I have a Visual C ++ program that opens a file in a single thread using FILE* fp = fopen(...). I want this thread to block the event object while another thread is reading the file, then signals the blocked thread when it is finished, and then close the file. Since it fpis shared between threads, I declared it as volatile FILE* fp. However, fread()it will not accept volatile as its argument FILE*. I tried using a local pointer with FILE* fpLocal = fp;in a thread that will call fread(), but that bothered me:
Error: a value of type "volatile FILE*" cannot be assigned to an entity of type "FILE*"
Naturally, it bothers me that maybe I'm wrong trying to open a file in one stream and read it in another first, although I don’t understand why (for now).
Can someone help me? Why can not I appoint volatile FILE* FILE*?
source
share