readerwriterqueue icon indicating copy to clipboard operation
readerwriterqueue copied to clipboard

the compilation time prompts: The object allocated on the heap may not be aligned 64

Open lovecomputer888 opened this issue 1 year ago • 4 comments

After using the following statement ReaderWriterQueue<int> q(100); , the compilation time prompts: The object allocated on the heap may not be aligned 64, I use MSVC(ver2022,c++14) to develop, how to solve it?

lovecomputer888 avatar Jul 20 '24 00:07 lovecomputer888

Can you post the full error message?

cameron314 avatar Jul 20 '24 01:07 cameron314

This code:dataQueue = new moodycamel::ReaderWriterQueue(1024); This is message: C4316 “moodycamel::ReaderWriterQueue<quint8,512>”: 在堆上分配的对象可能不是对齐 64

lovecomputer888 avatar Jul 20 '24 09:07 lovecomputer888

I have the same warning when use std::make_shared to create a object of moodycamel::BlockingReaderWriterQueuestd::string , or use std::make_shared to create a object who has an attribute of moodycamel::BlockingReaderWriterQueuestd::string

kth8384 avatar Apr 11 '25 07:04 kth8384

For objects allocated on the heap this can be normal. It's not a problem if the alignment to 64 is not respected, it's just a hint to potentially improve performance. You can define MOODYCAMEL_MAYBE_ALIGN_TO_CACHELINE before including the header to remove the alignment and silence this warning, if you like.

cameron314 avatar Apr 11 '25 12:04 cameron314