diff --git a/c/src/include/macros.h b/c/src/include/macros.h index 3688efca..4e636451 100644 --- a/c/src/include/macros.h +++ b/c/src/include/macros.h @@ -66,7 +66,7 @@ #endif #ifndef swap - #define swap(x, y, T) do { T SWAP = x; x = y; y = SWAP; } while (0) + #define swap(x, y) do { typeof(x) SWAP = x; x = y; y = SWAP; } while (0) #endif #if !(CL_COMPILER || TCC_COMPILER) diff --git a/c/src/p0025.c b/c/src/p0025.c index d1274c39..d26b6eeb 100644 --- a/c/src/p0025.c +++ b/c/src/p0025.c @@ -36,7 +36,7 @@ unsigned long long p0025() { BCD_int a = BCD_one, b = BCD_one; while (b.decimal_digits < 1000) { iadd_bcd(&a, b); - swap(a, b, BCD_int); + swap(a, b); answer++; } free_BCD_int(a); diff --git a/docs/src/c/lib/macros.rst b/docs/src/c/lib/macros.rst index 3303c5d9..77162ce4 100644 --- a/docs/src/c/lib/macros.rst +++ b/docs/src/c/lib/macros.rst @@ -30,7 +30,11 @@ View source code :source:`c/src/include/macros.h` .. c:macro:: max(a, b) min(a, b) - If these were not already defined, this header makes them + If these were not already defined, this header makes them. + +.. c:macro:: swap(x, y) + + Swap the names of two variables of the same type. .. c:macro:: likely(x) unlikely(x)