Table of Contents

iso646.h

iso646.h defines macros that let you spell out operators in plain English: and for &&, or for ||, not for !, and so on. It exists because some older national character sets used the code points for &, |, ~, and ! for other symbols, so alternative spellings were standardised in C95.

#include <iso646.h>
 
if (a and b)    // a && b
if (a or b)     // a || b
if (not a)      // !a
 
x = a bitand b; // a & b
x = a bitor b;  // a | b
x = a xor b;    // a ^ b
x = compl a;    // ~a
 
a and_eq b;     // a &= b
a or_eq b;      // a |= b
a xor_eq b;     // a ^= b

In C++ these are built-in keywords — you can use them without any header. In C, you need <iso646.h>. You are unlikely to encounter a machine where you cannot type &&, but you will occasionally see this header in embedded or legacy codebases, and it is worth recognising.

Practice

// compile: gcc -o iso iso.c
// run: ./iso
// description: use operator aliases from iso646.h; then try removing the include
 
#include <iso646.h>
#include <stdio.h>
 
int main(void) {
    int a = 1, b = 0;
 
    if (a and not b)
        puts("a is true and b is false");
 
    unsigned x = 0xFF;
    unsigned y = x bitand 0x0F;   // low nibble: 0x0F
    unsigned z = y bitor  0xF0;   // restore:    0xFF
    printf("x=0x%02X  y=0x%02X  z=0x%02X\n", x, y, z);
    return 0;
}

Now remove the #include <iso646.h> line and try to compile. On GCC/Clang you will get errors because and, not, bitand etc. are not keywords in C without the header. Put it back and it compiles. In C++ you can remove the include and it still compiles — that is the difference between a macro and a keyword.