c - Why does GCC emit a warning when using trigraphs, but not when using digraphs? -
code:
#include <stdio.h> int main(void) { ??< puts("hello folks!"); ??> } the above program, when compiled gcc 4.8.1 -wall , -std=c11, gives following warning:
source_file.c: in function ‘main’: source_file.c:8:5: warning: trigraph ??< converted { [-wtrigraphs] ??< puts("hello folks!"); ??> ^ source_file.c:8:30: warning: trigraph ??> converted } [-wtrigraphs] but when change body of main to:
<% puts("hello folks!"); %> no warnings thrown.
so, why compiler warn me when using trigraphs, not when using digraphs?
this gcc document on pre-processing gives pretty rationale warning (emphasis mine):
trigraphs not popular , many compilers implement them incorrectly. portable code should not rely on trigraphs being either converted or ignored. -wtrigraphs gcc warn when a trigraph may change meaning of program if converted.
and in gcc document on tokenization explains digraphs unlike trigraphs not potential negative side effects (emphasis mine):
there also 6 digraphs, c++ standard calls alternative tokens, merely alternate ways spell other punctuators. second attempt work around missing punctuation in obsolete systems. it has no negative side effects, unlike trigraphs,
Comments
Post a Comment