Skip to content

Tarik Billa

  • Web Development
    • html
    • vue.js
    • laravel
    • css
    • javascript
    • jquery
    • node.js
    • php
    • asp.net
  • Programming
    • python
    • java
    • c
    • c++
    • c#
  • git
  • android

alignof

What’s the difference between sizeof and alignof?

July 9, 2023 by Tarik

Well, “memory” is basically a huge array of bytes. However, most larger things like integers need more than 1 byte to store them — a 32 bit value, for example, would use 4 consecutive bytes of memory. Now, the memory modules in your computer aren’t usually “bytes”; they are also organized with a few bytes … Read more

Categories c++ Tags alignof, c++, c++11, sizeof Leave a comment

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

May 22, 2023 by Tarik

At least in standard C++, for anything you can make an array of (with length > 1), this will have to be true. If you have Foo arr[2]; and alignof(Foo) > sizeof(Foo), then arr[0] and arr[1] can’t both be aligned. As Zalman Stern’s example shows, though, at least some compilers will allow you to declare … Read more

Categories c++ Tags alignof, c++, c++11, memory-alignment Leave a comment

Tarik Billa

Software Engineer
tarikbilla@gmail.com
+8801884414000
  • Reuse a hash in YAMLApril 17, 2024
  • Dockerfile: how to redirect the output of a RUN command to a variable?April 16, 2024
  • How to cd to a directory with spaces in the directory name?April 16, 2024
  • Maximum MIME type length when storing the type in a databaseApril 16, 2024
  • What is the difference between Unit, Integration, Regression and Acceptance Testing?April 16, 2024
© 2026 Tarik Billa