Error passing volatile STD:: queue discard qualifier [- fpermissive] C 98

I have one

volatile std::queue<int> requestQueue;

When I try to call any of its methods (pop, push, empty, front, etc.) within a function, for example:

while (!requestQueue.empty()){
        ...do something
    }

I received the following error

robot.cpp:43:31: error: passing 'volatile std::queue<int>' as 'this' 
argument of 'bool std::queue<_Tp,_Sequence>::empty() 
const [with _Tp = int,_Sequence = std::deque<int,std::allocator<int> >]'
discards qualifiers [-fpermissive]

I found on the Internet that type conversion may be required, but I'm not sure if this is the case

Any ideas? Thank you in advance

to update

1) The program uses this data structure to store a series of requests so that the server can obtain requests at its own service rate

2) Volatile is used to support data sharing between functions running on different cores

3) The documentation for the library I use describes the following documentation about using

>Use static volatile to declare global variables so that they can be shared among functions running in different cores

Solution

Queue member functions are not volatile qualified, so you cannot use them on volatile queue instances Basically, if you have to have something volatile, then this is not the data structure you are looking for

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>