Forum Stats

  • 3,733,308 Users
  • 2,246,743 Discussions
  • 7,856,654 Comments

Discussions

Inclusion of cxxabi.h and iostream causes compile failure

steveire
steveire Member Posts: 9

[email protected]:/tmp$ cat test.cpp

#include <iostream>

#include <cxxabi.h>

int main()

{

  return 0;

}

[email protected]:/tmp$ /home/stephen/solaris-studio/SolarisStudio12.4-linux-x86-bin/solarisstudio12.4/bin/CC -std=c++03 -Wp,-I/usr/include/x86_64-linux-gnu/ -c test.cpp

"/home/stephen/solaris-studio/SolarisStudio12.4-linux-x86-bin/solarisstudio12.4/lib/compilers/CC-gcc/include/c++/4.8.2/cxxabi.h", line 131: Error: Only one of a set of overloaded functions can be extern "C".

1 Error(s) detected.

This happens on at least ubuntu and fedora.

Best Answer

  • Steve.Clamage-Oracle
    Steve.Clamage-Oracle Member Posts: 775
    Accepted Answer

    It happens on Oracle Linux too. There appears to be  conflict between the compiler's built-in declaratoin of this ABI function and what appears in the header. I have filed bug 20297923 for the problem.

    If you have a service contract, you can request an escalation and a fix in Studio 12.4. File the request via your support channel.

Answers

  • Steve.Clamage-Oracle
    Steve.Clamage-Oracle Member Posts: 775
    Accepted Answer

    It happens on Oracle Linux too. There appears to be  conflict between the compiler's built-in declaratoin of this ABI function and what appears in the header. I have filed bug 20297923 for the problem.

    If you have a service contract, you can request an escalation and a fix in Studio 12.4. File the request via your support channel.

  • steveire
    steveire Member Posts: 9

    Thanks, I can't even read the bug link because I don't have a "Support Identifier". I'm just trying to make sure CMake can build with the solaris studio compiler. I needed another work around for including fcntl.h and string in the same TU:

    www.cmake.org Git - cmake.git/commitdiff

  • The problem was what I guessed -- the compiler has an internal declaration for ABI helper functions that it needs to call, and in this case, its internal declaration for __cxa_atexit was wrong. There is nothing you can do in your code to compensate for this error, except:

    - don't include <cxxabi.h>, or

    - override <cxxabi.h> with a version that omits lines 131 and 132 (declaration of __cxa_atexit).

    If the code really needs cxxabi.h, you can't use the first option, and if it needs to use __cxa_atexit the second option won't work.

    I'm sorry I can't be more helpful.

  • Fedor-Oracle
    Fedor-Oracle Member Posts: 131

    > - don't include <cxxabi.h>, or

    Actually the problematic behavior is more complicated than just a conflict betwen external cxxabi.h and internal definition.

    There is no failure if you "just include" cxxabi.h.

    Our internal definition agrees with what is defined in cxxabi.h

    And compiler does emit error message if you include cxxabi.h after iostream.

    Something fishy happens between exactly these two headers, causing cxxabi.h to define atexit differently.

    It does not happen with other STL headers.

    Say, including <string> and then cxxabi.h works ok.

    > I needed another work around for including fcntl.h and string

    I'm not sure how you came from "fcntl.h and string" to "cxxabi.h and iostream".

    You also mention "stlport" in your cmake commit and I assume stlport is -library=stlport4.

    Which means it has nothing to do with -std=c++03/-std=c++11/-compat=g modes that use G++ STL headers.

    If you want to make your change only for sunCC -library=stlport4 then you can try hacking around with some additional #ifdefs

    but I would really like to know why that rather innocent fcntl.h causes the problem.

    regards,

      Fedor.

  • Fedor-Oracle
    Fedor-Oracle Member Posts: 131

    > Something fishy happens between exactly these two headers, causing cxxabi.h to define atexit differently.

    Hmm... it turns out that Steve was right.

    <iostream> causes compiler to use internal definition (to register static variable destruction) and then it conflicts.

    Similar problem will happen with any C++ code that needs static destruction and includes cxxabi.h at the same time.

    So there seems to be no easy way out (for -std=c++03/-compat=g/-std=c++11 on Linux).

  • steveire
    steveire Member Posts: 9

    Thanks for the extra information and follow-ups.

    "I'm not sure how you came from "fcntl.h and string" to "cxxabi.h and iostream"

    I didn't. It was a separate issue I encountered. Yes, I'm referring to using -library=stlport4 in the commit message. That is a separate error unrelated to the iostream/c++abi/libstdc++ issue. Sorry for the mixup. I don't think I investigated further why the include causes a problem.

  • If you are still having a problem with fcntl.h and string, please post it in a new thread and we'll take a look at it. :-)

This discussion has been closed.