c++ - Changing the linkage of a name -
an attempt change linkage of name i
made in code. legal in c/c++?
static int = 2; int i; int main() { return 0; }
in c++ code ill-formed (you have multiple definitions of variable i
) i.e standard conformant compiler required issue error message
$3.2.1 (c++03)
no translation unit shall contain more 1 definition of variable, function, class type, enumeration type or template.
in c99 code invokes undefined behaviour because 6.2.2/7 says
if, within translation unit, same identifier appears both internal , external linkage, behavior undefined.
Comments
Post a Comment