0
#include<iostream>

using namespace std;

int main(){
    __uint128_t a=0x12345678123456781234567812345678;

    return 0;
}

The constant has 8*4*8=128bits=16bytes,but the code raise the following warning:

main.cpp:8:19: warning: integer constant is too large for its type
    8 |     __uint128_t a=0xab345678123456781234567812345678;
      |                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

But in the following code:

#include<iostream>

using namespace std;

int main(){
    cout<<sizeof(__uint128_t);
    return 0;
}

It return 16 correctly.

My Ubuntu version is 20.04,64 bits
My gcc version is 9.4.0

user17732522
  • 16,968
  • 2
  • 24
  • 58
  • 3
    Does this answer your question? [How to create a 128-bit integer literal](https://stackoverflow.com/questions/51538694/how-to-create-a-128-bit-integer-literal). There's no support in gcc for 128-bit integer literals, unless the native long long type is 128 bits. You can check that with `sizeof(long long int)`. It's probably not, though. The answer in the linked duplicate shows how to make a user defined literal, if you like, to get over this handicap. – JohnFilleau Mar 14 '22 at 03:37
  • 1
    Unknown25001, `0x12345678123456781234567812345678` is not a 128-bit constant and its too big for a 64-bit one. – chux - Reinstate Monica Mar 14 '22 at 03:39
  • 1
    [gcc 7.3 128-bit unsigned integer operation](https://stackoverflow.com/q/60860827/995714) – phuclv Mar 14 '22 at 03:40

0 Answers0