Hi All,
Does the C++ standard tell function overloading can't be done with the
return types of two functions ? If so, is it true that the name
mangling scheme does not take the return type into account ?I know that
C++ standard does not tell anything about name mangling and only talks
bout function overloading. But, I have observed that the Metrowerks
Code Warrior compiler does take return type into the mangling scheme.
Is it not a bug with the compiler ?
Again, the fun part is that the symbols generated are different when I
declare one at a time. But, when I try to declare both it gives error.
I want to know how the compiler knows this in spite of the fact that
the symbols generated are different.
Regards,
Subhransu 5 1959
Subhransu Sahoo wrote:
Hi All,
Does the C++ standard tell function overloading can't be done with the
return types of two functions ?
Yes.
If so, is it true that the name
mangling scheme does not take the return type into account ?
This is unrelated. Any name-mangling might well include the return-type
if any. This would help detecting declaring functions with the wrong
return-type. The code will compile but not link.
I know that
C++ standard does not tell anything about name mangling and only talks
bout function overloading. But, I have observed that the Metrowerks
Code Warrior compiler does take return type into the mangling scheme.
Is it not a bug with the compiler ?
Nope.
>
Again, the fun part is that the symbols generated are different when I
declare one at a time. But, when I try to declare both it gives error.
I want to know how the compiler knows this in spite of the fact that
the symbols generated are different.
This part I don't understand.
>
Regards,
Subhransu
/Peter
Subhransu Sahoo wrote:
Hi All,
Does the C++ standard tell function overloading can't be done with the
return types of two functions ?
Yes, it does. See C++98, par 13.1/2:
"Certain function declarations cannot be overloaded:
- Function declarations that differ only in return type...
If so, is it true that the name
mangling scheme does not take the return type into account ?
Can't comment on that. I would think it need not, but OTOH, nothing
prevents it from not.
I know that
C++ standard does not tell anything about name mangling and only talks
bout function overloading. But, I have observed that the Metrowerks
Code Warrior compiler does take return type into the mangling scheme.
Is it not a bug with the compiler ?
No, as the standard does not mention mangling (according to you).
Again, the fun part is that the symbols generated are different when I
declare one at a time. But, when I try to declare both it gives error.
I want to know how the compiler knows this in spite of the fact that
the symbols generated are different.
I'm afraid I'm not a compiler writer :-), so I don't know. I do think
that the generation of the symbols have little to do with whether or
not it compiles, though. IOW the lookup-set does not necessarily use
symbol names. But I honestly don't know.
Regards,
Werner
Subhransu Sahoo wrote:
Hi All,
Does the C++ standard tell function overloading can't be done with the
return types of two functions ? If so, is it true that the name
mangling scheme does not take the return type into account ?I know that
C++ standard does not tell anything about name mangling and only talks
bout function overloading. But, I have observed that the Metrowerks
Code Warrior compiler does take return type into the mangling scheme.
Is it not a bug with the compiler ?
Again, the fun part is that the symbols generated are different when I
declare one at a time. But, when I try to declare both it gives error.
I want to know how the compiler knows this in spite of the fact that
the symbols generated are different.
did you try to link two separate files with the same function and
different return values ?
file1.cpp-----
int f()
{
return 1;
}
==============
file2.cpp------
double f()
{
return 1.0;
}
---------------
if you can link these two files, then than would be interesting.
"Subhransu Sahoo" <sy******@gmail .comwrote:
>Hi All,
Does the C++ standard tell function overloading can't be done with the return types of two functions ?
C and C++ functions can be called without catching their return
values. That is, you can call a function like this:
int i = myfunc(a, b, c);
or like this:
myfunc(a, b, c);
If you've defined two functions with identical signatures except for
return type, and you use the second type of call, the compiler has no
way of determining which function you want to call. That's why you
can't overload a function by changing only its return type.
--
Tim Slattery Sl********@bls. gov
"Subhransu Sahoo" <sy******@gmail .comwrote in message
news:11******** **************@ h48g2000cwc.goo glegroups.com.. .
Does the C++ standard tell function overloading can't be done with the
return types of two functions ?
Yes.
If so, is it true that the name
mangling scheme does not take the return type into account ?I know that
C++ standard does not tell anything about name mangling and only talks
bout function overloading.
You have just answered your own question.
But, I have observed that the Metrowerks
Code Warrior compiler does take return type into the mangling scheme.
Is it not a bug with the compiler ?
Can you write a program that the standard says is correct but the compiler
will not handle it?
Again, the fun part is that the symbols generated are different when I
declare one at a time. But, when I try to declare both it gives error.
I want to know how the compiler knows this in spite of the fact that
the symbols generated are different.
How about an example? This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Steven Bethard |
last post by:
Philippe C. Martin wrote:
> class Debug_Stderr:
> __m_text = ''
> __m_log_text = None
> __m_dbg = None
> __m_refresh_count = 0
<rant>
I don't see the benefit in 99.9% of cases for making class variables
|
by: sunny |
last post by:
Hi,
I was trying to call a function in an an asm file from a C
file(driver).
In c file the funcrtion is defined as:
extern int foo(int,int);
In the asm file the function is defined as _foo.
when I link the 2 binaries in VC++ it works fine but with DDK this
gives as error saying _foo@8 not found.
|
by: Tim Slattery |
last post by:
Does the C++ language standard mandate a particular name-mangling
method?
I'm trying to use the Entrust toolkit to create a C++ program that
encrypts and decrypts files. Entrust supplies header files defining
their objects and functions, and *.so files (I'm on a Sun Sparc
machine running Solaris) containing the implementation of the
functions.
I'm compiling with the GNU g++ compiler. According to the
|
by: yyy |
last post by:
my question is rather theoretical than practical in the pure programming
aspect...
is "name mangling" the same as "name decorating" ?
browsing the web, you might find multiple people saying "yes", but i
vaguely remember having read that it's not exactly like that
one might say that "name mangling" is a part of c++ compiler specification
and is a naming scheme to support function overloading
|
by: noleander |
last post by:
I need to use a library supplied by someone else: libjpeg.lib. This is a
plain C library. I do not have the source code. I do have the header *.h
files. When I run dumpbin on the libjpeg.lib, it contains symbols (entry
points) like:
jpeg_read_header
I'm trying to link my program with this library. My program is in Visual
C++. The link fails with link-time errors such as:
| |
by: David Wade |
last post by:
Folks,
Does any one know of any "name mangling" software that allows standard C
with long names to be linked? Any suggestions for a better place to look? I
have tried putting various searchs into google to no avail.
Dave.
|
by: sam_cit |
last post by:
Hi Everyone,
I read somwhere that c++ compiler does name mangling of functions
which is why c source code can't invoke functions from object files
that were generated using c++ compiler. Can anyone tell in detail as to
what name mangling is all about?
|
by: jason.cipriani |
last post by:
Does anybody know if C++0x is going to change C++ name mangling at
all? Such as, standardizing name mangling instead of leaving it up to
the compiler?
Jason
|
by: Megalo |
last post by:
why not make "name mangling" of C++ standard so should be possible
to call
the classes and the functions of C++ from other C++ compiler
thanks
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |