0

is not a real problem but more a curiosity, what's more I do not want some stupid question, the point is playing with Visual Studio (x64), I have noticed that if a Structure is present a wchar*

#include <iostream>

struct {
    wchar_t* pTest;
    unsigned int uTest;
} Test;

int main()
{
    std::cout << "sizeof(Test) - " << sizeof(Test) << "\n\n";
}

sizeof(Test) - 16 http://cpp.sh/3lbg will not have to be 12 ?

#include <iostream>

struct {
    wchar_t* pTest;
    //unsigned int uTest;
} Test;

int main()
{
    std::cout << "sizeof(Test) - " << sizeof(Test) << "\n\n";
}

sizeof(Test) - 8 http://cpp.sh/4bld

#include <iostream>

struct {
    //wchar_t* pTest;
    unsigned int uTest;
} Test;

int main()
{
    std::cout << "sizeof(Test) - " << sizeof(Test) << "\n\n";
}

sizeof(Test) - 4 http://cpp.sh/7xwjl

I understand that behind there a logic, but I'm confused about who are the rules relating to this.

Cœur
  • 37,241
  • 25
  • 195
  • 267
DXRW4E
  • 1

0 Answers0