What is the UINT64_C macro in C?

I saw this code:

bool contains_zero_byte(uint64 v) {
  return (((v)-UINT64_C(0x0101010101010101))
        & ~(v)&UINT64_C(0x8080808080808080));
}

What is UINT64_C(0x0101010101010101) doing? UINT64_C is a macro defined as:

// Appends the correct suffix to a 64-bit unsigned integer literal.
#define UINT64_C(c) c ## ULL

The ## token instructs the preprocessor to “paste together” the tokens on either side of it. So UINT64_C(0x0101010101010101) results in the output 0x0101010101010101ULL.

But what is ULL in 0x0101010101010101ULL? I’ll write more about these suffixes in the next post.

Tagged #c, #macros, #programming.

Similar posts

More by Jim

Want to build a fantastic product using LLMs? I work at Granola where we're building the future IDE for knowledge work. Come and work with us! Read more or get in touch!

This page copyright James Fisher 2017. Content is not associated with my employer. Found an error? Edit this page.