Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

about name mangling

38 views
Skip to first unread message

Rosario19

unread,
Jun 3, 2015, 3:34:18 AM6/3/15
to
why here, in C++, at point of vew of name mangling
int f(int a){}
and
char* f(int a){}
have the same name?

at last here seems so...

Wouter van Ooijen

unread,
Jun 3, 2015, 4:06:02 AM6/3/15
to
Rosario19 schreef op 03-Jun-15 om 9:34 AM:
Because in C++ the return type is not part of the signature of a
function: it plays no role in determining which function is called,
hence there is no need at link time for different names for those two
functions.

(There are languages, for instance Ada, where the return type *is* part
of the signature. This adds some power to the language, but makes
parsing - both by humans and by compilers and other tools - of the
language much harder.)

Wouter

Jorgen Grahn

unread,
Jun 3, 2015, 3:45:01 PM6/3/15
to
I think there is some more fundamental reason the return type is not
part of the signature in C++ -- Stroustrup writes about it in "Design
and Evolution", I think.

/Jorgen

--
// Jorgen Grahn <grahn@ Oo o. . .
\X/ snipabacken.se> O o .
0 new messages