C++

C++ Development Environment

2024-08-29. Category & Tags: C++, Programming

IDE # VS (Visual Studio) Community (Free Version) # (TODO) CodeBlocks # 中文版(含 MinGW GCC): https://github.com/anbangli/codeblocks-cn VS Code (VSC) # (TODO) on windows # For English, see official doc: https://code.visualstudio.com/docs/languages/cpp Install msys2-x86_64-20240727.exe (use the default path, which is on C:…). Install w64devkit-x64-2.0.0.exe (change path to C:, it will add w64devkit folder.)

C-CPP-Programming-in-case-of

2022-04-23. Category & Tags: C, C++, CPP, Programming

Data Structure Alignment 数据结构对齐 # x86-64 architecture # Overall rule: any data structure/element should be accessed by CPU with minimum CPU cycles. A 32bit CPU can access 4Bytes in one cycle, while a 64bit one can access 8Bytes. When a memory access is not aligned, it is said to be misaligned (wiki). Thus, there are two practical rules for us to understand compiler’s padding: Rule 1: any basic data structure/element/variable should be aligned so that their beginning address is divisible (任何变量的开始地址都能被自己的大小整除,即:当被访问的数据长度为 n 字节时,数据地址为 n 字节对齐。). ...