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.
👋 I'm Jim, a full-stack product engineer. Want to build an amazing product and a profitable business? Read more about me or Get in touch!

More by Jim

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