Hello
My question is regarding "weak external symbols". Consider the
following eg.
class test
{
public :
int func1(void); {cout <<"func1";}
int func2(void);
}
int test :: func2(void)
{
cout <<"func2";
}
I compiled this piece of code using the CC for PPC processor, version
"cygnus-2.7.2-960126 egcs-971225". The readelf output shows that the
func1 has weak binding and func2 has normal global binding. Please let
me know why is the function whos implementation is with in the class
definition has weak binding and the one with its implementatin outside
the class definition has normal global binding.
regards
Vinay 4 3723
Possibly because the function within the class definition is seen as a
candidate for inlining and the one whose definition lies outside the class
definition is not.
Not really familiar with the term weak binding but thats my best guess on
whats happening.
Vinay posted: Hello
My question is regarding "weak external symbols". Consider the following eg.
class test { public : int func1(void); {cout <<"func1";}
Syntax error. Lose the semicolon.
int func1() { cout << "func1"; }
int func2(void); }
int test :: func2(void) { cout <<"func2"; }
I compiled this piece of code using the CC for PPC processor, version "cygnus-2.7.2-960126 egcs-971225". The readelf output shows that the func1 has weak binding and func2 has normal global binding. Please let me know why is the function whos implementation is with in the class definition has weak binding and the one with its implementatin outside the class definition has normal global binding.
regards Vinay
Vinay wrote: Hello
My question is regarding "weak external symbols". Consider the following eg.
class test { public : int func1(void); {cout <<"func1";} int func2(void); }
int test :: func2(void) { cout <<"func2"; }
I compiled this piece of code using the CC for PPC processor, version "cygnus-2.7.2-960126 egcs-971225". The readelf output shows that the func1 has weak binding and func2 has normal global binding. Please let me know why is the function whos implementation is with in the class definition has weak binding and the one with its implementatin outside the class definition has normal global binding. ...
Because the first one is inline function. Inline functions can (and
normally will) have multiple definitions in multiple translation units.
If the compiler decides to generate a normal (non-inline) body for this
function, it is more than likely that this body will be present in
multiple object files. Without normal binding that would result in an
error at linking stage. Weak binding directs the linker to choose one
body and discard the others, no error reported.
We had a relevant discussion a couple of days ago. See topic "Inlines
with external linkage".
BTW, this is a compiler-related question. It should be asked in a
compiler-related newsgroup, not here.
--
Best regards,
Andrey Tarasevich
Andrey Tarasevich wrote: ... If the compiler decides to generate a normal (non-inline) body for this function, it is more than likely that this body will be present in multiple object files. Without normal binding that would result in an
^^^^^^^^^^^^^^^ ^^^^^^^
I meant "With normal binding ...".
error at linking stage. Weak binding directs the linker to choose one body and discard the others, no error reported.
--
Best regards,
Andrey Tarasevich This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Gabriel Zachmann |
last post by:
Is it correct to say that strong/weak typing does not make a difference
if one does not use any pointers (or adress-taking operator)?
More concretely, I am thinking particularly of Python vs C++.
So, are there any examples (without pointers, references, or adress-taking),
which would have a different result in Python and in C++?
I would appreciate all insights or pointers to literature.
TIA,
|
by: Wenjie |
last post by:
Hello,
I read someone posted assertions that even the (public) member
function is not static, there are probably only one copy of the
code in the executable. Then except the dependency/independency
on the lifecycle of the object, what is the significant
differences between public member functions and public static
member functions?
|
by: festiv |
last post by:
Hi there,
I want to learn how the compiler is implementing the dynamic binding. where
can i read about this subject (the hole process).
thanks.
|
by: Neelesh Bodas |
last post by:
Hi all,
does C++ give a way to declare a specific symbol as a "weak symbol"?
In 'C', one can use #pragma directive.
Is this still a legal way in C++ ? Is there a (better?) alternative?
|
by: Søren Dreijer |
last post by:
Hi,
I have a mixed C#, managed C++ and unmanaged C++ project.
The managed class calls a method which exists in an unmanaged singleton
class. During the entire lifetime of the application, this gives no problems
whatsoever. However, upon shutdown an exception pops up:
"The string binding is invalid"
If I call the singleton method from inside a purely unmanaged class, I
| |
by: Nelis Franken |
last post by:
Good day. Thanks for the previous help on binding member functions to
use as predicates for STL functions (original example applied to
sort()). The technique to use Boost's bind() works well, except when
used with STL's random_shuffle(). The following code demonstrates a
working call (on sort()) and a call that generates an error (on
random_shuffle()), both using the same technique.
The code:
#include <algorithm>
|
by: John Nagle |
last post by:
Are weak refs slower than strong refs? I've been considering making the
"parent" links in BeautifulSoup into weak refs, so the trees will release
immediately when they're no longer needed. In general, all links back
towards the root of a tree should be weak refs; this breaks the loops
that give reference counting trouble.
John Nagle
|
by: Tom Gur |
last post by:
Hi,
What is early/late binding ?
|
by: Immortal Nephi |
last post by:
My project grows large when I put too many member functions into one
class. The header file and source code file will have approximately
50,000 lines when one class contains thousand member functions. Is it
normal how C++ Compiler can compile large class without any problem?
Didn't C++ Compiler have rules to limit the number of member
functions?
One big object has complex operations how member variables and member
functions can be...
|
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: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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.
| |