Mixing C and assembly sources and build with cmake

CMake supports assembler out of the box. Just be sure to enable the “ASM” language in your project. If an assembler source file needs preprocessing, also set the source file’s compilation options: project(assembler C ASM) set_property(SOURCE foo.s APPEND PROPERTY COMPILE_OPTIONS “-x” “assembler-with-cpp”) add_executable(hello foo.s bar.c)

Why does unique_ptr instantiation compile to larger binary than raw pointer?

Because std::make_unique<int[]>(100) performs value initialization while new int[100] performs default initialization – In the first case, elements are 0-initialized (for int), while in the second case elements are left uninitialized. Try: int *p = new int[100](); And you’ll get the same output as with the std::unique_ptr. See this for instance, which states that std::make_unique<int[]>(100) is … Read more

Can modern x86 hardware not store a single byte to memory?

TL:DR: On every modern ISA that has byte-store instructions (including x86), they’re atomic and don’t disturb surrounding bytes. (I’m not aware of any older ISAs where byte-store instructions could “invent writes” to neighbouring bytes either.) The actual implementation mechanism (in non-x86 CPUs) is sometimes an internal RMW cycle to modify a whole word in a … Read more