Asked • 04/26/19

What is ":-!!" in C code?

I bumped into this strange macro code in [/usr/include/linux/kernel.h][1]: /* Force a compilation error if condition is true, but also produce a result (of value 0 and type size_t), so the expression can be used e.g. in a structure initializer (or where-ever else comma expressions aren't permitted). */ #define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:-!!(e); })) #define BUILD_BUG_ON_NULL(e) ((void *)sizeof(struct { int:-!!(e); })) What does `:-!!` do? [1]: https://github.com/torvalds/linux/blob/ff2d8b19a3a62559afba1c53360c8577a7697714/include/linux/kernel.h#L677-L682

2 Answers By Expert Tutors

By:

Matthew C. answered • 11/25/19

Tutor
New to Wyzant

Systems-Level Programmer

Cheryl F. answered • 05/04/19

Tutor
New to Wyzant

Scientific Programming is Science aided by Software

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.