I've seen in a site that int main(int argc, char* argv<::>)
can also be used as a signature of main
. Surprisingly, The following program:
int main(int argc, char* argv<::>)
{
return 0;
}
compiles withput any warnings in GCC , as well as clang. It also compiles in C++.
So, how is it that int main(int argc, char* argv<::>)
is a valid signature of main
?
char* argv<::>
is equivalent to char* argv[]
. <:
and :>
used here are digraphs.
In all aspects of the language, the six tokens79)
<: :> <% %> %: %:%:
behave, respectively, the same as the six tokens
[ ] { } # ##
except for their spelling. 80)
Foot note:
79) These tokens are sometimes called ‘‘digraphs’’.
80) Thus [
and <:
behave differently when ‘‘stringized’’ (see 6.10.3.2), but can otherwise be freely interchanged.
An example:
%: define stringize(a) printf("Digraph \"%s\" retains its spelling in case of stringization.\n", %:a)
Calling the above macro
stringize( %:);
will print
Digraph "%:" retains its spelling in case of stringization.