Inline functions not implemented Sun C++ Workshop 5.0?

Inline functions not implemented Sun C++ Workshop 5.0?

Post by Shea Marti » Wed, 12 Feb 2003 14:59:34



First a simple example of what I did:
class_a.h
---------
class A
{
public:
    void funcA();

Quote:}

class_a.cc
----------
#include "class_a.h"
inline
void A::funcA()
{
    //do something

Quote:}

main.cc
-------
#include "class_a.h"
int main()
{
    //do something here
    A a;
    a.funcA();

    return 0;

Quote:}

I compile like this, using sun C++ workshop compiler 5.0
CC -c -o A.o class_a.cc
CC -o myprogram A.o main.cc.

I get a linking error telling me that the symbol funcA() was reference in
main, and is not implemented.  Has anyone experienced this problem?  Know of
a solution?  Know of a better forum to post this question?  (I couldn't find
any forums on sun's website that dealt with anything other than WS7.0 (ONE),
or Java.)

Thanks in advance,

Shea Martin.

~S

 
 
 

Inline functions not implemented Sun C++ Workshop 5.0?

Post by Paul Pluzhniko » Thu, 13 Feb 2003 14:05:31



> class_a.cc
> ----------
> #include "class_a.h"

What is the purpose of this 'inline' ?

Quote:> inline
> void A::funcA()
> {
>     //do something
> }
....
> I get a linking error telling me that the symbol funcA() was reference in
> main, and is not implemented.

You got exactly what you deserve ;-)
You told the compilier (while it was compiling "class_a.cc"):

  don't generate any code for A::fincA(), inline it instead
  (into any code that uses it in the same compilation unit).

and that's exactly what the compiler did.

If you want the 'A::funcA()' definition to *also* be available
while compiling "main.cc", you have to '#include "class_a.cc"'
into it (or better yet move your inline function definition to
"class_a.h" where it belongs).

Cheers,
--
In order to understand recursion you must first understand recursion.

 
 
 

1. Sun WorkShop 5.0: multiply defined inline functions

Hello,

I am using Sun WorkShop C++ 5.0 to compile an application. Because I
need a debug version, I add '-g' to the command line:


One of the side-effects of '-g' is that inline functions are no longer
expanded. The problem is that during linking, I get the following error:


dxfreader.o file.o gdsreader.o ie3dreader.o lyread.o main.o object.o
polysplit.o reader.o stringres.o symbol.o tlcreader.o xform.o
cifwriter.o dxfwriter.o gdswriter.o ie3dwriter.o pswriter.o tlcwriter.o
writer.o checklist.o datatarget.o ciflex.o cifparse.o resources.o

<snip>
ld: fatal: symbol `void*operator new(unsigned,void*)' is multiply
defined:
        (file asciireader.o and file dxfwriter.o);
ld: fatal: symbol `std::ios_base&std::nounitbuf(std::ios_base&)' is
multiply defined:
        (file asciireader.o and file dxfwriter.o);
<snip>

I *think* that all the multiply defined functions were declared as
inline, and I have the impression that the compiler simply ignores the
inline keyword (which it should when using -g). But it shouldn't, of
course, complain about multiply defined symbols then.

Any idea how I can avoid this. The code, BTW, compiles fine under gcc
and MSVisualC++ 5.

Thanks for you help!


2. matrox meteor

3. SUN CC 5.0: shared libraries refuse to close - missing inline template functions!

4. dc area linux bbs's?

5. Problems with Sun WorkShop C++ 5.0 on Sloaris 8

6. RH 7.1 Install doesn't recognize CD-ROM

7. Looking for Sun WorkShop C++ Compiler 5.0

8. Master Boot Record

9. SUN Workshop C++ Compiler 5.0 dead slow

10. ild: message with Sun Workshop C++ 5.0

11. Problems compiling glib (solaris 5.6, Sun Workshop C++ 5.0)

12. Sun Workshop C++ 5.0 - exception bug

13. Sun Workshop 5.0 c++