-lquadmath
Description
This option enables the 128-bit quadruple-precision floating-point number library. Add this link option for compilation when using the quadruple-precision floating-point number library.
Usage
- Compilation command before the change:
1 2
gcc test.c -o test.out -lquadmath -DAARCH64_QUADMATH ./test.out
- Compilation command after the change:
You do not need to explicitly specify the -DAARCH64_QUADMATH macro. The __aarch64__ predefined macro is enabled by default on the AArch64 platform.
1 2
gcc test.c -o test.out -lquadmath ./test.out
- Suggestions on inventory project adaptation:
No file modifications are required; the added -DAARCH64_QUADMATH macro is invalid and has no impact.
- Sample code: test.c
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
#include <stdio.h> #include <math.h> #include <quadmath.h> #define USE_FLOAT128 1 int main() { #ifdef USE_FLOAT128 typedef __float128 long_double_t; #else typedef long double long_double_t; #endif long_double_t ld=0.1; long_double_t res; int* i = (int*) &res; i[0] = i[1] = i[2] = i[3] = 0xdeadbeef; for(ld = 0.0000000000000001; ld < __LDBL_MAX__; ld += 0.0000000000000001) { res = tanq(ld); printf("%08x-%08x-%08x-%08x\r", i[0], i[1], i[2], i[3]); } return 0; }
Result
The compilation result shows that the 128-bit floating-point number calculation result is displayed, indicating that the 128-bit calculation is enabled.
Parent topic: Static Compilation Optimization