Category : alignment

Given the following C++ class: class X { public: uint8_t a; uint32_t b[256] __attribute__ ((aligned(32))); }; How can the compiler ensure that the storage for b is 32-byte aligned, when an instance of X is presumably word-aligned? Does the aligned attribute only specify alignment relative to the object instance start address? If so, what is ..

Read more

I would like to add QTextEdit widgets in a layout and alternate the alignment QVBoxLayout *lt = new QVBoxLayout; for(int i=0;i<5;i++) { text1 = new QTextEdit; text1->setText("Hello world !" + QString::number(i)); text1->setMaximumSize(100,30); lt->addWidget(text1); lt->setAlignment(Qt::AlignLeft); if(i%2) { lt->setAlignment(Qt::AlignRight); } else { lt->setAlignment(Qt::AlignLeft); } } setLayout(lt); However, the QTextEdits, are all align on the left. Is there ..

Read more

I would like to add QTextEdit widgets in a layout and alternate the alignment QVBoxLayout *lt = new QVBoxLayout; for(int i=0;i<5;i++) { text1 = new QTextEdit; text1->setText("Hello world !" + QString::number(i)); text1->setMaximumSize(100,30); lt->addWidget(text1); lt->setAlignment(Qt::AlignLeft); if(i%2) { lt->setAlignment(Qt::AlignRight); } else { lt->setAlignment(Qt::AlignLeft); } } setLayout(lt); However, the QTextEdits, are all align on the left. Is there ..

Read more

I have the following C++ code: DLLExport int _CDECL nncpu_evaluate_incremental( int player, int* pieces, int* squares, NNCPUdata** nncpu) { assert(nncpu[0] && uint64_t(&nncpu[0]->accumulator) % 64 == 0); Position pos; pos.nncpu[0] = nncpu[0]; pos.nncpu[1] = nncpu[1]; pos.nncpu[2] = nncpu[2]; pos.player = player; pos.pieces = pieces; pos.squares = squares; return nncpu_evaluate_pos(&pos); } using this datastructure typedef struct DirtyPiece ..

Read more

The relevant paragraph is [basic.stc.dynamic.allocation]/3 (emphasis mine): (3) For an allocation function other than a reserved placement allocation function, the pointer returned on a successful call shall represent the address of storage that is aligned as follows: (3.1) — If the allocation function takes an argument of type std​::​align_­val_­t, the storage will have the alignment ..

Read more