[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: [OT] C (was: QA uploads primer)



On Wednesday 17 June 2009, Boyd Stephen Smith Jr. wrote:
> In <[🔎] 200906171954.59429.v13@v13.gr>, Stefanos Harhalakis wrote:
> >On Wednesday 17 June 2009, Boyd Stephen Smith Jr. wrote:
> >> In <[🔎] 200906171857.57749.v13@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".)

oh :(

> >
> >#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.

That's why I used them outside the quotes :)

> 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.)

I guess such a bug report would annoy gcc developers :-)


Reply to: