Hacker News new | ask | show | jobs
by segfaultbuserr 2374 days ago
Digraphs were supposed to be a easier-to-read alternative to trigraphs. Unfortunately, the extended list of digraphs with many additional logic operators by C++ never entered C, i.e.

    %:%:    ##
    compl   ~
    not     !
    bitand  &
    bitor   |
    and     &&
    or      ||
    xor     ^
    and_eq  &=
    or_eq   |=
    xor_eq  ^=
    not_eq  !=
C only has basic ones (still more intuitive than trigraphs).

    <:  [
    :>  ]
    <%  {
    %>  }
    %:  #
Last time, I had to type a C program on a touchscreen, and those symbols were extremely difficult to enter. I knew digraphs can help, but then realized that I couldn't use the digraphs for logic operators without programming C under C++.
2 comments

C has the named operators as macros in <iso646.h>.
Great tip, thanks. Have to remember this magic ISO standard number.
Also, have to remember to #undef them in any file that includes something that includes iso646.h.
Should've been `bitxor`