Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / C

<iso646.h> — alternative operator spellings

The <iso646.h> header defines eleven macros replacing C operators. It changes their spelling, not their behavior.

Version: C23; repository compiler flag, production runtime not attested

Syntax

#include <iso646.h>

In C, <iso646.h> provides object-like macros, not new keywords or functions. Include it before using these names.

The complete mapping is: and → &&, and_eq → &=, bitand → &, bitor → |, compl → ~, not → !, not_eq → !=, or → ||, or_eq → |=, xor → ^, xor_eq → ^=.

After expansion, ordinary operator rules apply, including precedence. and and or compute logical truth and short-circuit. Binary bitand and bitor operate on bits. Because bitand expands to &, it can also be used as the unary address-of operator, which does not perform a bitwise operation. not performs logical negation, whereas compl flips bits. and_eq, or_eq, and xor_eq expand to compound assignment operators. In contrast, not_eq expands to !=, the inequality comparison operator.

Examples

#include <iso646.h>
#include <stdio.h>

int main(void)
{
    unsigned flags = 6u;
    flags and_eq 3u;
    flags or_eq 8u;
    flags xor_eq 2u;

    unsigned masked = (compl flags) bitand 15u;
    unsigned combined = (flags bitor 1u) xor 3u;
    int ok = (flags not_eq 0u) and (not 0 or 0);

    printf("%u %u %u %d\n", flags, masked, combined, ok);
    return 0;
}

Result

8 7 10 1

The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.

Sources