Go to main content

Oracle® Developer Studio 12.6 发行版的新增功能

退出打印视图

更新时间: 2017 年 7 月
 
 

C++ 编译器更改

本部分包括编译器通用的新增和更改的功能中介绍的更改。

此发行版中特定于 C++ 编译器的新功能如下:

  • 新的 section 属性-C++ 编译器现在提供了一个新的 section 属性,该属性指定特定节中存在的一个变量或函数。

  • 针对 -xO3内联行为更改-支持其正文小于调用方开销的函数的自动内联。此外,当与 –xspace 选项一起使用时,-xO3-xO4 会导致最小的代码大小。

  • –xlibmopt 选项更改–xlibmopt 选项已通过 –%none–archive–shared 子选项进行了增强。

  • 在 Linux 上静态链接的 libCrunG3libCrunG3 是通过选项 -compat=g-std=c++03-std=c++11-std=c++14 中的任意一个编译的 C++ 程序所需的运行时支持库。

    在 Oracle Solaris 上,缺省情况下,libCrunG3 在需要时进行动态链接。它是 Oracle Solaris 操作系统的一部分,因此,用户程序始终可以找到它。在 Linux 上,如果您动态链接了 libCrunG3.so.1,则需要向该库提供您的程序。为避免此问题,在 Linux 上,libCrunG3 缺省情况下将在需要时静态链接。

  • 函数重载解决方法中改进的错误报告-Oracle Developer Studio 和 Oracle Solaris Studio 中以前的编译器在报告对重载的函数的不明确或无法解析的调用时没有提供详细消息。在 Oracle Developer Studio 12.6 中,错误报告已改进。以下示例说明了改进的错误报告功能。

    Example 1:
    
    % cat ex1.cc
    void f(int n, int* ptr);
    void f(int, int, int);
    void f(int);
    void foo()
    {
        f(1, 2);
    }

    以前的编译器会报告类似以下内容的消息:

    % CC -c ex1.cc
    "ex1.cc", line 7: Error: Could not find a match for f(int, int) needed in
    foo().
    1 Error(s) detected.
    

    Oracle Developer Studio 12.6 C++ 编译器会提供有关为何无法找到匹配项的更多信息。

    % CC -c ex1.cc
    "ex1.cc", line 7: Error: Could not find a match for f(int, int) needed in
    foo().
    "ex1.cc", line 1: Note: Candidate 'f(int, int*)' is not viable: argument
    'ptr' can't be converted from 'int' to 'int*'.
    "ex1.cc", line 3: Note: Candidate 'f(int)' is not viable: too many arguments.
    "ex1.cc", line 2: Note: Candidate 'f(int, int, int)' is not viable: too few
    arguments.
    Example 2:
    
    % cat ex2.cc
    struct A;
    struct B {
        B(const A&);
    };
    struct D1 : B {};
    struct D2 : B {};
    struct A {
        A();
        operator  D1() const;
        operator  D2&() volatile ;
    };
    void foo(A& ra)
    {
        A va;
        B vb  = ra;
    }

    以前的编译器会报告类似以下内容的消息:

    % CC -c ex2.cc
    "ex2.cc", line 19: Error: Overloading ambiguity between "A::operator D1()
    const" and "B::B(const A&)".
    "ex2.cc", line 19: Error: Cannot use A to initialize B.
    2 Error(s) detected.

    Oracle Developer Studio 12.6 C++ 编译器会提供有关二义性的更多信息。

    % CC -c ex2.cc
    "ex2.cc", line 19: Error: Type conversion 'A' -> 'B' is ambiguous.
    "ex2.cc", line 12: Note: Viable candidate 'A::operator D1() const'.
    "ex2.cc", line 4: Note: Viable candidate 'B::B(const A&)'.
    "ex2.cc", line 13: Note: Viable candidate 'A::operator D2&() volatile'.
    "ex2.cc", line 19: Error: Cannot use A to initialize B.
    
    You can disable generation of the Notes by using the CC option
        -features=no%note

有关更多信息,请参见Oracle Developer Studio 12.6: C++ User’s GuideCC(1) 手册页。