Sun Compiler Compatibility with g++
I am new to C++ so I believe this is a basic question.
I was given the job of compiling a C++ program to be compatible with Sun compiler 5.5 Patch 113817-19 2006/10/13 on Solaris 9 Sparc. Since I did not have the Sun One Studio 8 I compiled the program using G++ 3.4.6. Question: will this program compiled with g++ 3.4.6 satisfy the requirements.
Any help would be appreciated.
--Acevez
[412 byte] By [
aceveza] at [2007-11-27 4:36:38]

# 1
You have to ask those imposing the requirement what they actually care about.
If you need binary compatibility, the answer is "No." Object code produced from C++ source code by any version of Sun C++ cannot be linked with object code produced from C++ source code by any version of g++.
If the requirement is that the source code be successfully compiled by Sun ONE Studio 8 (C++ 5.5), the answer is "maybe." Limitations include the following:
1. Every compiler has bugs. Code might trigger a bug in one compiler but not in a different compiler.
2. g++ has extensions not supported by Sun C++ 5.5. Source code that uses an unsupported extension probably won't work the same (and probably won't compile) with Sun C++ 5.5. If you write code for use with g++, you might not know when you are using a g++ extension.
3. The default version of the C++ Standard Library used by Sun C++ is libCstd, which does not fully conform to the C++ standard. Sun C++ also provides the STLport library as an option. Standard-conforming source code that works with g++ and its libstdc++ might not work with Sun C++ libCstd, but will probably work wtih STLport. If you are not allowed to use STLport with Sun C++ and write code for g++, you might write code that depends on features not supported by libCstd.
In summary, you are asking questions about portability. The short answer is that
A. C++ object code is in general not portable among C++ compilers, and
B. You don't know whether source code is portable until you port it.
That said, most programmers find most of the time that well-written code that has portability in mind works fine with Sun C++.
Finally, Sun Studio 8 is obsolete. It would be better to use the current release, Sun Studio 11, which is free. You can get it here:
http://developers.sun.com/sunstudio
Sun Studio 11 is source and binary compatible with Sun Studio 8, in the following sense:
Valid source code that works with Sun Studio 8 will also work with Sun Studio 11.
Object code produced by Sun Studio 8 can be linked into programs built by Sun Studio 11.
Good luck!