Test pseudo-namespaces in C
In C you can create pseudo-namespaces by abusing structs of function pointers, making function calls look like `module.func(x)` instead of `func(x)`. A lot of people online spout that this creates overhead, but this should show that clang>=15.0.7 will still inline such function calls. GCC 11.3.1 is unable to inline the function, but will still call the function directly.
This commit is contained in:
21
build.sh
Executable file
21
build.sh
Executable file
@@ -0,0 +1,21 @@
|
||||
#!/bin/bash
|
||||
|
||||
requirements=("cmake" "gdb")
|
||||
|
||||
for cmd in $requirements; do
|
||||
if ! command -v gdb; then
|
||||
echo "gdb not found"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
mkdir -p build
|
||||
(cd build
|
||||
rm * -rf
|
||||
CC=clang cmake ..
|
||||
make -j2
|
||||
)
|
||||
|
||||
gdb ./build/main -batch -ex 'disassemble main' > dump.asm
|
||||
gdb ./build/main -batch -ex 'disassemble succ' 1>> dump.asm 2>/dev/null || true
|
||||
|
||||
Reference in New Issue
Block a user