In <200906171954.59429....@v13.gr>, Stefanos Harhalakis wrote: >On Wednesday 17 June 2009, Boyd Stephen Smith Jr. wrote: >> In <200906171857.57749....@v13.gr>, Stefanos Harhalakis wrote: >> >Same thing for the trigraphs. >> >> puts("What??!"); /* ;) */ > >I meant that they are not very popular and that they are not covered in > most books or tutorials.
I know. I was attempting to make a joke by misusing a trigraph. (Per the standard that would output "What|\n".) > Thus, it is not obvious that this: > >#include<stdio.h> >int main() { printf("??!??/n"); } > >may not output what the user expects (depending on the compiler) Agreed. >or why this: > >#include <stdio.h> >int main() { printf("%c\n", "123"<:2:>); } > >will properly compile and output "3" Those aren't trigraphs. They aren't substituted during phase 1 of translation. They are only recognized as independent tokens, never (e.g.) inside a string literal. They also stringify differently than the tokens they can be substituted for. Different stringification: #define str(x) #x int main() { puts(str(??!)); puts(str(<:)); } outputs "|\n<:\n" not "|\n[\n". Parsed after phase 1: #define gltk(x, y) x ## y #define str(x) # x #define estr(x) str(x) int main() { puts("??" "!" gtk2(<, :) 1 gtk2(:, >)); } outputs "?!\n", not "\n". (GCC pukes on it saying ":>" and "<:" are not preprocessing tokens, but that's non-conformant per 6.4.1.) -- Boyd Stephen Smith Jr. ,= ,-_-. =. b...@iguanasuicide.net ((_/)o o(\_)) ICQ: 514984 YM/AIM: DaTwinkDaddy `-'(. .)`-' http://iguanasuicide.net/ \_/
signature.asc
Description: This is a digitally signed message part.