c++ - How is `int main(int argc, char* argv<::>)` a valid signature of main? -


this question has answer here:

i've seen in site int main(int argc, char* argv<::>) can used signature of main. surprisingly, following program:

int main(int argc, char* argv<::>) {   return 0; } 

compiles withput warnings in gcc , clang. compiles in c++.

so, how int main(int argc, char* argv<::>) valid signature of main?

char* argv<::> equivalent char* argv[]. <: , :> used here digraphs.

c11: 6.4.6 (p3):

in aspects of language, 6 tokens79)

<: :> <% %> %: %:%: 

behave, respectively, same 6 tokens

[ ] { } # ## 

except spelling. 80)


foot note:
79) these tokens called ‘‘digraphs’’.
80) [ , <: behave differently when ‘‘stringized’’ (see 6.10.3.2), can otherwise freely interchanged.

an example:

%: define  stringize(a) printf("digraph \"%s\" retains spelling in case of stringization.\n", %:a)     

calling above macro

stringize( %:);   

will print

digraph "%:" retains spelling in case of stringization. 

Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -