Skip to content
Latchkey

gcc "warning: multi-character character constant" treated as error in CI

Single quotes denote one character. Writing more than one character inside them, like 'ab', makes a multi-character constant with implementation-defined value, which -Wmultichar warns about and -Werror turns into a failure.

What this error means

A build with -Werror stops at a literal that uses single quotes around several characters, frequently a string that should use double quotes.

gcc
main.c:4:13: error: multi-character character constant [-Werror=multichar]
    4 |   int x = 'abcd';
      |             ^~~~~~

Common causes

How to fix it

Use double quotes for strings

  1. Change the single quotes to double quotes when you meant a string.
  2. Rebuild to confirm the warning is gone.
C
const char *s = "abcd";   /* not 'abcd' */

Silence intentional multichar locally

If the packed constant is deliberate, disable just -Wmultichar for that file rather than dropping -Werror everywhere.

gcc
gcc -Wno-multichar -c fourcc.c

How to prevent it

  • Reserve single quotes for one character and use double quotes for strings; only suppress -Wmultichar where a packed multi-character constant is intended.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →