Questions tagged [alignof]
21 questions
1
vote
1 answer
The sizeof and _Alignof value of a structure
Which of the following are true in Standard C?
(A) The sizeof a structure is equal to:
the relative address of its last member plus the sizeof its last member. (I know this cannot be true.)
the relative address of its last member plus the…

FedKad
- 493
- 4
- 19
0
votes
0 answers
Why using alignof on non-typed types is valid?
The data shows that alignof is used type-id, but why I can use Eigen::Matrix4f like below.
Eigen::Matrix4f t_localizer = ndt.getFinalTransformation();
std::cout << "t_localizer alignof: " << alignof(t_localizer); // ??
std::cout << "t_localizer…

daohu527
- 452
- 4
- 15
0
votes
1 answer
C2x: if _Alignof(array type) yields the alignment of the element type, then will it be useful to permit _Alignof(incomplete array type)?
This code is invalid:
int x = _Alignof(int[]);
Note: GCC produces:
error: invalid application of '__alignof__' to incomplete type 'int[]'
while Clang produces:
Per Semantics (emphasis added):
When applied to an array type, the result…

pmor
- 5,392
- 4
- 17
- 36
0
votes
1 answer
error: storage class may not be specified here when using __align() in MDK ARM uVision v5 ARM Compiler 5
I am migrating a project from CubeIDE (GCC) to the most comprehensive software development solution for Arm®-based microcontrollers uVision (ARM Compiler 5) and have a difficulty using __align keyword.
CubeIDE code which compiles fine in…

Joej
- 1
- 2
0
votes
1 answer
What is the use of alignof operator?
I want to know where to use alignof operator in c++14
#include
struct Empty {};
struct Foo {
int f2;
float f1;
char c;
};
int main()
{
std::cout << "alignment of empty class: " << alignof(int*) << '\n';
std::cout…

Ankit Shukla
- 313
- 3
- 11
-3
votes
1 answer
_Alignof with operand of variable length array type: is there a contradiction in the standard?
C2x, 6.5.3.4 The sizeof and _Alignof operators, Semantics, 2 (emphasis added):
If the type of the operand is a variable length array type, the operand is evaluated;
otherwise, the operand is not evaluated and the result is an integer…

pmor
- 5,392
- 4
- 17
- 36