One more language extension

Upcoming SunStudio Express 3 will include one more c++ language extension. Recently I have implemented explicit template definition aka forward declaration of explicit instantiations. Now this extension is available under -Qoption ccfe -features=gcc command line option.

In the code below compiler will not instantiate (explicitly and implicitly) any members of class S<int>. So it will not waste a time on code generation and optimization. The only source code file should contain explicit template instantiation to successfully link the program.

% cat test.h
template <typename T>
struct S
{
  void foo();
};

template <typename T>
void S<T>::foo()
{
  // a lot of code here
}

extern template struct S<int>;

% cat inst.cc
#include "test.h"

template struct S<int>;

% cat main.cc
#include "test.h"

int main()
{
  S<int> s;
  s.foo();
}
Comments:

Hi, I dont know whether it is right place to ask a question. In GCC, C++, I can use __PRETTY_FUNCTION__ to get the complete function declaration. Is there any similar preprocessor macro in SUNWSpro compilers? AFAIK, This feature is not there in SUNWSpro. SUN compilers support only __func__. Do you have any ideas of getting the full function declaration with minimal overhead?? Thank you

Posted by DP on November 07, 2006 at 11:28 AM MSK #

It's right place to ask questions about Sun C++. I think there is not any way to get full function declaration if compiler does not support this functionality. We do not plan to implement __PRETTY_FUNCTION__ in the near future but we will definitely implement it one day.

Posted by Simon on November 09, 2006 at 08:21 AM MSK #

Is the features=gcc flag available in the current version of Sun Studio available from sun.com? It doesn't appear to work for me and I just downloaded what I thought was the latest version from sun.com yesterday. CC -V says: CC: Sun C++ 5.8 2005/10/13 Thanks, Ali

Posted by Ali on January 24, 2007 at 06:36 PM MSK #

To use "-Qoption ccfe -features=gcc" you need Sun C++ 5.9 (Sun Studio 12). You can download it here http://developers.sun.com/sunstudio/downloads/index.jsp. Also I recommend to install patch-01 for it. Please note this flag enables features which are not released yet. So use it on your own risk.

Posted by guest on February 03, 2008 at 04:08 AM MSK #

Post a Comment:
  • HTML Syntax: NOT allowed
About

atanasyan

Search

Categories
Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today