top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

Facebook Login
Site Registration
Print Preview

Thread-local destructor registration with C++11 on PowerPC

0 votes

how can I configure GCC to emit the calls to __cxa_thread_atexit() for destructor registration? On a Linux PowerPC target I see the registration of destructors, but not on the powerpc-rtems target. I guess I missed a configuration option or define. Has someone a hint for me?

posted Jun 26, 2013 by anonymous

Looking for an answer?  Promote on:
Facebook Share Button Twitter Share Button Google+ Share Button LinkedIn Share Button Multiple Social Share Button
Ok, I found it. It is connected with __cxa_exit(). There seem to be two ways  to enable it. One is the enable=__cxa_atexit configure option. The second  is default_use_cxa_atexit in gcc/config.gcc.

Similar Questions
+2 votes

GCC gives a warning for this program:

int main()
    int x;

test.cpp: In function 'int main()':
test.cpp:3:9: warning: unused variable 'x' [-Wunused-variable]

If I add an "unused" attribute with the GNU syntax:

int x __attribute__((unused));

the warning goes away.

However, if I use the C++11 syntax:

int x [[unused]];

the warning remains, and I also get:

test.cpp:3:20: warning: 'unused' attribute directive ignored [-Wattributes]

Does anyone know about gcc plans to support the attributes with C++11 syntax.

0 votes

I'm running Ubuntu 13.04 on an intel machine and I want to cross compile helloworld.c so that the resulting binary will execute on Ubuntu on a powerpc machine.

So something simple like:

gcc helloworld.c --target powerpc-linux -o helloworldppc

But the answer seems to always come back how to cross compile gcc itself...

+1 vote

I need some help in understanding why my GCC didn't consider this an issue. I have a function that was constructing a path to a daemon program based on the location of the shared object file where this code is. Something similar to this:

namespace {
 std::string ConstructPath()
 int lastSlash(0);
 std::string pathVar;
 Dl_info dl_info;


 pathVar = dl_info.dli_fname;
 lastSlash = pathVar.find_last_of('/');
 if(std::string::npos == lastSlash)
 // no slashes given ... must be that *.so
 // is in the current directory
 pathVar = "mydaemond";
 pathVar.erase(pathVar.begin() + (lastSlash + 1), pathVar.end());

 // first check if we can find the daemon
 // introducing sub-scope to ensure the file object is closed
 std::ifstream test(pathVar.c_str());
 throw std::runtime_error("cannot find mydaemond");

 // *** the below statement wasn't there originally, the
 // *** function simply exited after the forced-scope block above,
 // *** however, the function *did* have the return type
 return pathVar;

My comments above the final return statement illustrate what my question is about. Why wasn't this a problem? There was no return statement and yet, the code compiled fine. I'm using GCC 4.4.4 on CentOS 6.2. Is this just a problem with the 4.4.4 compiler that was fixed? I'm betting there's some subtlety in C++ here that I'm not yet aware of and I'd like to be schooled.

+1 vote

Are automatic variables (that are defined in functions, lambdas, blocks) in C++11 thread local? Is the following code correct:

auto f1 = [
 SomeClass1 obj1;
 double z = obj1.f2(y);
 return cos(z);

// Some function which creates several threads which call f1.

+1 vote

I wanted to ask what is the GCC C++ equivalent implementation of Windows _ MyFirst and _MyLast vector pointers?

These give direct access to the vectors first and last element, but they are not present in the GCC implementation of the vector class.

Useful Links with Similar Problem
Contact Us
+91 9880187415
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Karnataka INDIA.