473,387 Members | 1,463 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Local static variables

Hi,

I'm trying to port my O/S kernel from C to C++. I am using g++ with the
following command-line switches:

-Wall -fno-builtin -fno-rtti -fno-exceptions -fno-enforce-eh-specs
-nostartfiles -nostdinc -nostdlib

And ld to link it with the -nostdlib switch. There is no C library
available to link with and I assumed I had disabled it with the above
switches. However, if I try and use a local static variable, for example in:

class MyClass {
private:
MyClass() {}
~MyClass() {}

MyClass(const MyClass&);
MyClass& operator=(MyClass);

public:
static MyClass& getInstance() {
static MyClass instance;
return instance;
}
};

I get undefined references to __cxa_atexit and __dso_handle. I assume
these are C library functions? What are they for?

Why are they necessary simply for dealing with static variables; I
thought they [static variables] were just stored in the global data area
like global variables? I obviously have not provided the correct
switches to g++ for it to fully stop trying to use the C library. I'd be
very grateful if someone could inform me of the correct/complete ones
and tell me what's going on here!

Thanks, any help is gratefully received!

Richard Hayden.
Jul 22 '05 #1
1 1594
Richard Hayden wrote:
Hi,
Hi!

[...]
I get undefined references to __cxa_atexit and __dso_handle. I assume
these are C library functions? What are they for?


I can only say, that atexit() is a C - Library function, which is used,
I think by the sopurce the compiler makes out of your program. There are
some necessary cleanups, which you don;t see, but they have to be done
at time of terminating a program.

HTH && kind regards
Nicolas
Jul 22 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Tim Hill | last post by:
I'm just getting up to speed on Java, and have a question about local class behavior. Here's a mini-app to illustrate: interface Foo { void print(); } class LocalClassTest { public static...
2
by: Jonathan | last post by:
I'm puzzled by Python's behavior when binding local variables which are introduced within exec() or execfile() statements. First, consider this simple Python program: # main.py def f() : x = 1...
2
by: Simon Harvey | last post by:
Hi everyone, I'm still abit confused about static methods accessing locally declared variables. For example public static bool executeNonQuery(){ SqlCommand cmd; SqlConnection con;
23
by: Timothy Madden | last post by:
Hello all. I program C++ since a lot of time now and I still don't know this simple thing: what's the problem with local functions so they are not part of C++ ? There surely are many people...
9
by: Rory Campbell-Lange | last post by:
We have a set of classes using static methods to retain reference variables between operations. The problem is that the static variables are not reset between operations when used through...
55
by: Zytan | last post by:
I see that static is more restricted in C# than in C++. It appears usable only on classes and methods, and data members, but cannot be created within a method itself. Surely this is possible in...
8
by: Rahul | last post by:
Hi, I have the following code and i get a compilation error, int main() { class Locale { public: static int c;
1
by: danep2 | last post by:
Let me start by saying that this is more a question about principle than practice - with the speed of today's computers it's probably rarely an actual issue. Still I'd like to know... If I have...
1
by: Neil.Fang.CN | last post by:
Supposing I have a class like this: class SomeManager { public: static SomeManager& getInstance(); } SomeManager& SomeManager::getInstance() {
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
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,...
0
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...
0
jinu1996
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.