从此

C/C++、汇编、Rust、Golang

综合/最新



通用

ABI - 应用程序二进制接口(Application Binary Interface);可通过C语言统一交互接口:extern "C",或用 WebAssembly (Wasm)。
Windows的PE(Portable Executable)格式、Linux的ELF(Executable and Linkable Format)格式。
Linux 系统的编译器是 Clang(取代GCC),Windows 中的编译器是 MSVC;两大ABI家族:Itanium C++ ABI和MSVC C++ ABI。
C++20 Modules - 取代了 *.h 头文件方式,Clang 名为 *.cppm,MSVC为 *.ixx,可直接实现而无需 *.cpp。
  即 import std; 取代了老式写法 #include <标准库名> 或 #include "自定义类.h"。
  Clang 启用模块化 clang++ -std=c++20 ...

  模块化用法:
    sudo apt install libc++-dev libc++abi-dev -y
    # 隐式模块 - /usr/lib/llvm-18/include/c++/v1/module.modulemap 会自动编译和导入 import ;
    clang++ -std=c++23 -stdlib=libc++ cpp23helloworld.cpp -fsyntax-only -fmodules -fimplicit-modules

    # 显式模块 - 查找 libc++-dev 的标准库模块文件并编译
    find /usr/lib/ -name "std.cppm" 2>/dev/null
    clang++ -std=c++23 -stdlib=libc++ -Wno-reserved-identifier -Wno-reserved-module-identifier --precompile -o std.pcm /usr/lib/llvm-18/share/libc++/v1/std.cppm
    clang++ -std=c++23 -stdlib=libc++ -fmodule-file=std=std.pcm cpp23helloworld.cpp -fsyntax-only

  import <print>; // or 导入显式模块 import std; // or #include <print> // 头文件位于 /usr/lib/llvm-18/include/c++/v1/print。
  int main() {
    std::println("Hi!"); // -std=c++23
    return 0;
  }

其他