alignof

How do I fix “The program issued a command but the command length is incorrect.” error when calling Process32First()?

扶醉桌前 提交于 2019-12-11 03:38:47
问题 GetLastError tells me I'm getting the "The program issued a command but the command length is incorrect." error when calling Process32First() (see code below). I found one post that looked helpful (http://social.msdn.microsoft.com/Forums/is/vcgeneral/thread/6f43716f-fdd3-4c92-bfba-6a23178c32bf), but I'm not sure if this is my problem. I've tried building a program that includes only "stdafx.h" , <iostream> , <Windows.h> and <TlHelp32.h> to test __alignof(PROCESSENTRY32) , but I still get a

What's the difference between sizeof and alignof?

六眼飞鱼酱① 提交于 2019-11-29 22:50:50
What's the difference between sizeof and alignof? #include <iostream> #define SIZEOF_ALIGNOF(T) std::cout<< sizeof(T) << '/' << alignof(T) << std::endl int main(int, char**) { SIZEOF_ALIGNOF(unsigned char); SIZEOF_ALIGNOF(char); SIZEOF_ALIGNOF(unsigned short int); SIZEOF_ALIGNOF(short int); SIZEOF_ALIGNOF(unsigned int); SIZEOF_ALIGNOF(int); SIZEOF_ALIGNOF(float); SIZEOF_ALIGNOF(unsigned long int); SIZEOF_ALIGNOF(long int); SIZEOF_ALIGNOF(unsigned long long int); SIZEOF_ALIGNOF(long long int); SIZEOF_ALIGNOF(double); } will output 1/1 1/1 2/2 2/2 4/4 4/4 4/4 4/4 4/4 8/8 8/8 8/8 I think I don't

What's the difference between sizeof and alignof?

断了今生、忘了曾经 提交于 2019-11-28 18:27:16
问题 What's the difference between sizeof and alignof? #include <iostream> #define SIZEOF_ALIGNOF(T) std::cout<< sizeof(T) << '/' << alignof(T) << std::endl int main(int, char**) { SIZEOF_ALIGNOF(unsigned char); SIZEOF_ALIGNOF(char); SIZEOF_ALIGNOF(unsigned short int); SIZEOF_ALIGNOF(short int); SIZEOF_ALIGNOF(unsigned int); SIZEOF_ALIGNOF(int); SIZEOF_ALIGNOF(float); SIZEOF_ALIGNOF(unsigned long int); SIZEOF_ALIGNOF(long int); SIZEOF_ALIGNOF(unsigned long long int); SIZEOF_ALIGNOF(long long int);

Is it always the case that sizeof(T) >= alignof(T) for all object types T?

人走茶凉 提交于 2019-11-28 05:42:33
For any object type T is it always the case that sizeof(T) is at least as large as alignof(T) ? Intuitively it seems so, since even when you adjust the alignment of objects like: struct small { char c; }; above what it would normally be, their "size" is also adjusted upwards so that the relationship between objects in an array makes sense while maintaining alignment (at least in my testing . For example: struct alignas(16) small16 { char c; }; Has both a size and alignment of 16. At least in standard C++, for anything you can make an array of (with length > 1), this will have to be true. If

Is it always the case that sizeof(T) >= alignof(T) for all object types T?

痴心易碎 提交于 2019-11-27 05:35:28
问题 For any object type T is it always the case that sizeof(T) is at least as large as alignof(T) ? Intuitively it seems so, since even when you adjust the alignment of objects like: struct small { char c; }; above what it would normally be, their "size" is also adjusted upwards so that the relationship between objects in an array makes sense while maintaining alignment (at least in my testing. For example: struct alignas(16) small16 { char c; }; Has both a size and alignment of 16. 回答1: At least