Hallo, ich habe ein Problem mit dem uint64_t Datentyp. Mein Testprogramm sieht so aus:
1 | #include <inttypes.> |
2 | #include <stdio.h> |
3 | |
4 | #define SET_BIT64(port, bit) ((port) = (uint64_t)((uint64_t)(port) | (uint64_t)(1ULL << (bit)))) |
5 | #define IS_BIT_SET64(port, bit) ((uint64_t)((uint64_t)(port) & (uint64_t)(1ULL << (bit))) ? 1 : 0) |
6 | |
7 | void dbg(unsigned long long b) { |
8 | for (int i = 0; i < 64; ++i) { |
9 | if (IS_BIT_SET64(b, i)) { |
10 | printf("X"); |
11 | } else { |
12 | printf("."); |
13 | } |
14 | } |
15 | printf("\n"); |
16 | } |
17 | |
18 | void test() { |
19 | unsigned long long test; |
20 | |
21 | for (int i = 0; i < 64; ++i) { |
22 | SET_BIT64(test, i); |
23 | dbg(test); |
24 | } |
25 | } |
26 | |
27 | int main(int argc, char **argv) { |
28 | test(); |
29 | return 0; |
30 | } |
Es werden nur die Bits 0-31 richtig gesetzt bzw. ausgelesen. Die Bits 33-64 funktionieren nicht. Woran könnte das liegen? Vielen Dank schon einmal für eine hilfreiche Antwort.