Page 1 of 2 12 Last
  • Jump to page:
    #1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    18
    Rep Power
    0

    Pass by reference in CPP


    Function Call

    inline void intllist::copy(const intllist& d)
    {
    Scanner wiz((Collection&)d);
    while (wiz.increment())
    append(intcast(wiz));--------------------------->Call
    present = (intnode*)(void*)getfirst();

    }

    Function body

    inline intllist& intllist::append(int& d)
    {
    llist::append(new intnode(d));
    return *this;
    }


    Error:

    Error: Formal argument d of type int& in call to intllist::append(int&) requires an lvalue.


    what is the Problem??

    Thanks
    Revathi R
  2. #2
  3. Contributed User
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jun 2005
    Posts
    4,404
    Rep Power
    1871
    > append(intcast(wiz));--------------------------->Call
    ...
    > Error: Formal argument d of type int& in call to intllist::append(int&) requires an lvalue.

    The problem is that casts are r-values, not l-values (that's what the error message is telling you).

    Try say
    Code:
    int temp = intcast(wiz);
    append(temp);
    Note the use of [code][/code] tags here to show code in a nice presentable format (it also preserves indentation). Please use them when posting code in future.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    18
    Rep Power
    0
    Thanks it worked :)

    if you don't mind will you enlight me the same

    even i am doing a direct cast in call why it does not worked :(


    Thanks in advance
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    18
    Rep Power
    0
    Hello

    I am working on C++ code i have compiled the code it has generated .so files

    Code:
    class A
    {
    sum()
    }
    A-->compiled-->A.so

    now my requirement is to call a sun() function from
    some other function that i have written.

    like this

    Code:
    main()
    {
    sum();--->here class A's sum() must be called.
    }
    How can i call sum() from main()?


    any help is highly appriciated.


    Regards
    Revathi R
  8. #5
  9. Contributed User
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jun 2005
    Posts
    4,404
    Rep Power
    1871
    > if you don't mind will you enlight me the same
    > even i am doing a direct cast in call why it does not worked
    I told you already - a cast is not an l-value.
    It's as invalid as trying to do this
    int *ptr = &42;
    does NOT generate a pointer to some anonymous integer containing the value 42

    > sum();--->here class A's sum() must be called.
    I thought this was beginning of the book C++.
    To call a member function, you need an instance of the object.

    Code:
    A someVar;
    someVar.sum();
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    18
    Rep Power
    0
    Humm

    Thank you.

    I am migrating C++ code written on 4.3 sun CC to 5.8 sun CC
    when i have compiled the code on Production environmet it generates .so files

    all the generated .so's are working fine

    but i have problem with one .so file,[e the functionality is it has to open a log file and write to logfile. but it is not creating log file]

    so i would like to Debug that.

    as you mentioned

    Code:
    classname obj;
    obj.fun();

    i am writting a new function called main() from which i am calling functions of .so

    main wont be known about class's and functions of that .so

    so my question is how can i make classes and funtions of .so visible to main() so that i from main i can trae out



    Thanks,
    Revathi R
  12. #7
  13. Contributed User
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jun 2005
    Posts
    4,404
    Rep Power
    1871
    So you have an A.cpp compiled down the .so file.

    Do you also have a A.h file describing the interface?
    You should have, if you want this to work.

    Then in your main.cpp, you begin with
    #include "A.h"
    along with any other header files you need.

    Post actual error messages if you get stuck.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper
  14. #8
  15. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    18
    Rep Power
    0
    Thanks ...


    I am Getting some liker error

    Code:
    Makefile:160: warning: overriding commands for target `.C.o'
    ../../../../../etc/sparc/wsmkinclude.common:260: warning: ignoring old commands for target `.C.o'
    Makefile:163: warning: overriding commands for target `.c.o'
    ../../../../../etc/sparc/wsmkinclude.common:264: warning: ignoring old commands for target `.c.o'
    ksh ../../../../../libs/general/src/versionString.C > versionString.C; CC  -c -xildoff -fast -O3 -compat=4 -features=extensions -i -DSYSTEMV -DCGM  -I/u01/apps/oracle_client/product/10.2.0/precomp/public -I../../../../../libs/af/include -I../../../../../libs/graphics/include -I../../../../../libs/motif/include -I../../../../../libs/rwextensions/include -I/u04/net/rtp-netapp1/vol/build/nwwls/devspace/thirdparty/SunOS/5.6/rwav/ver09.1/workspaces/SOLARIS26/SUNPRO42/0s -I/u04/net/rtp-netapp1/vol/build/nwwls/devspace/thirdparty/SunOS/common/zlib-1.1.3/include -I../../../../../libs/general/include -I../../../../../libs/pixmaps/include -I. -I../../../../../libs/tableGateway/include -I../../../../../libs/tableGatewayWriteback/include -I../../../../../libs/general/include -I../../../../../libs/gateway/include -I../../../../../libs/expressions/include -I../../../../../libs/modelGateWay/include -I../../../../../libs/configuration/include -I../../../../../libs/rwextensions/include -I../../../../../libs/expressions/include -I../../../../../libs/rwdbextensions/include -I../../../../../libs/ipc3/include -I../../../../../libs/xml/include -I../../../libs/perform/include -I/u04/net/rtp-netapp1/vol/build/nwwls/devspace/thirdparty/SunOS/5.6/rwav/ver09.1/workspaces/SOLARIS26/SUNPRO42/0s -DWM_VERSION=\"mauiLoader.0.9\" -DWM_PRODUCT=\"Prospect\" versionString.C
    CC  -ptv -xildoff -fast -O3 -compat=4 -features=extensions -i -DSYSTEMV -DCGM  -L../../../libs/lib -L../../../../../libs/lib -L/u04/net/rtp-netapp1/vol/build/nwwls/devspace/thirdparty/SunOS/5.6/rwav/ver09.1/workspaces/SOLARIS26/SUNPRO42/0s/lib -I/u04/net/rtp-netapp1/vol/build/nwwls/devspace/thirdparty/SunOS/common/expat/xmlparse -L/usr/ccs/lib FileLoadEventGenerator.o main.o CommandEnv.o LoaderJob.o versionString.o /u04/net/rtp-netapp1/vol/build/nwwls/devspace/thirdparty/SunOS/5.6/rwav/ver09.1/workspaces/SOLARIS26/SUNPRO42/0s/lib/dborlib.o \
                     -nolib -lperform -ltableGateway -lmodelGateWay -lgateway -lconfiguration -lxml -lparser -lexpressions -lareas -lipc3 -lgeneral -lrwdbextensions -lrwextensions -Bdynamic  /u04/net/rtp-netapp1/vol/build/nwwls/devspace/thirdparty/SunOS/5.6/rwav/ver09.1/workspaces/SOLARIS26/SUNPRO42/0s/lib/libora0s.a /u04/net/rtp-netapp1/vol/build/nwwls/devspace/thirdparty/SunOS/5.6/rwav/ver09.1/workspaces/SOLARIS26/SUNPRO42/0s/lib/libdbt0s.a /u04/net/rtp-netapp1/vol/build/nwwls/devspace/thirdparty/SunOS/5.6/rwav/ver09.1/workspaces/SOLARIS26/SUNPRO42/0s/lib/libtls0s.a /u04/net/rtp-netapp1/vol/build/nwwls/devspace/thirdparty/SunOS/5.6/rwav/heap/lib/librwheap.a /u04/net/rtp-netapp1/vol/build/nwwls/devspace/thirdparty/SunOS/common/zlib-1.1.3/lib.sparc/libz.a -L/u01/apps/oracle_client/product/10.2.0/lib32 -lclntsh -lnnz10 -lkstat -lnsl -lsocket -lgen -ldl -lsched /u04/net/rtp-netapp1/vol/build/nwwls/devspace/thirdparty/SunOS/common/expat/lib.sparc/libexpat.a ../../../../../libs/lib/libgeneral.a ../../../../../libs/lib/libtableGatewayWriteback.a -lsocket -lnsl -lintl -lgen -Bstatic -lC -Bdynamic -ldl -Bstatic -lcomplex -lsunmath -Bdynamic -lthread -lm -lc -nolib -o commander.static
    Undefined                       first referenced
     symbol                             in file
    WmExpSimpleNumericFunctionNode::preeval(RWEString&, WmExpState*, FilterableCollection*, RWOrdered*, int) ../../../../../libs/lib/libexpressions.a(wmexpmathsfunctionnode.o)
    WmExpSimpleNumericFunctionNode::WmExpSimpleNumericFunctionNode(const WmExpSimpleNumericFunctionNode&) ../../../../../libs/lib/libexpressions.a(wmexpmathsfunctionnode.o)
    WmExpSimpleNumericFunctionNode::WmExpSimpleNumericFunctionNode(const char*, AttrType) ../../../../../libs/lib/libexpressions.a(wmexpmathsfunctionnode.o)
    WmExpSimpleNumericFunctionNode::optimise(WmExpState*) ../../../../../libs/lib/libexpressions.a(wmexpmathsfunctionnode.o)
    ld: fatal: Symbol referencing errors. No output written to commander.static
    gmake: *** [commander.static] Error 1

    I could see in WmExpSimpleNumericFunctionNode::preeval(RWEString&, WmExpState*, FilterableCollection*, RWOrdered*, int)
    in code which comes down to libgeneral.a

    libgeneral.a also linked ../../../../../libs/lib/libgeneral.a above


    will you enlight what was the issue

    Regards
    Revathi R
  16. #9
  17. Contributed User
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jun 2005
    Posts
    4,404
    Rep Power
    1871
    Are you sure that those symbols are in the libgeneral.a file?

    Try say
    nm libgeneral.a | grep -i WmExpSimpleNumericFunctionNode

    My first thought was library ordering, but libgeneral.a follows libexpressions.a.

    The only other reasons I can think of are
    - libgeneral.a wasn't built successfully, so it's missing the object file of interest.
    - There is a spelling mistake in the caller (in libexpressions).
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper
  18. #10
  19. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    18
    Rep Power
    0
    oops i am sorry

    The code getdown to
    libexpressions.acontains the declarations of Prototypes.


    nm libexpressions.a| grep -i WmExpSimpleNumericFunctionNode
    [131] | 0| 0|NOTY |GLOB |0 |UNDEF |__0feWmExpSimpleNumericFunctionNodeHpreevalR6JRWEStringP6KWmExpStateP6UFilterableCollectionP6JRWOrd eredi
    [132] | 0| 0|NOTY |GLOB |0 |UNDEF |__0feWmExpSimpleNumericFunctionNodeIoptimiseP6KWmExpState
    [147] | 0| 0|FUNC |GLOB |0 |UNDEF |__0oeWmExpSimpleNumericFunctionNodectPCc6IAttrType
    [148] | 0| 0|FUNC |GLOB |0 |UNDEF |__0oeWmExpSimpleNumericFunctionNodectRC6eWmExpSimpleNumericFunctionNode
    [42] | 7580| 16|FUNC |LOCL |0 |2 |__0oeWmExpSimpleNumericFunctionNodedt1v
    [105] | 0| 0|NOTY |GLOB |0 |UNDEF |__0feWmExpSimpleNumericFunctionNodeHpreevalR6JRWEStringP6KWmExpStateP6UFilterableCollectionP6JRWOrd eredi
    [106] | 0| 0|NOTY |GLOB |0 |UNDEF |__0feWmExpSimpleNumericFunctionNodeIoptimiseP6KWmExpState
    [115] | 0| 0|FUNC |GLOB |0 |UNDEF |__0oeWmExpSimpleNumericFunctionNodectPCc6IAttrType
    [116] | 0| 0|FUNC |GLOB |0 |UNDEF |__0oeWmExpSimpleNumericFunctionNodectRC6eWmExpSimpleNumericFunctionNode
    [36] | 3552| 16|FUNC |LOCL |0 |2 |__0oeWmExpSimpleNumericFunctionNodedt1v
  20. #11
  21. Contributed User
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jun 2005
    Posts
    4,404
    Rep Power
    1871
    Yes, we know they're unresolved in libexpressions.

    What about libgeneral ?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper
  22. #12
  23. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    18
    Rep Power
    0
    bash-2.03# nm libgeneral.a | grep -i WmExpSimpleNumericFunctionNode
    bash-2.03#
  24. #13
  25. Contributed User
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jun 2005
    Posts
    4,404
    Rep Power
    1871
    in code which comes down to libgeneral.a

    libgeneral.a also linked ../../../../../libs/lib/libgeneral.a above
    So in other words, your previous statement that libgeneral had these symbols is in fact wrong.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper
  26. #14
  27. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    18
    Rep Power
    0
    yes
  28. #15
  29. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Posts
    18
    Rep Power
    0
    Code:
    /opt/SUNWspro/bin/CC -o msggen  msggen.o licensemessage.o ../../../../libs/lib/libgeneral.a
    Undefined                       first referenced
     symbol                             in file
    cerr                                ../../../../libs/lib/libgeneral.a(string.o)
    unsafe_ostream::operator<<(long)              ../../../../libs/lib/libgeneral.a(string.o)
    operator delete(void*)                            msggen.o
    operator new(unsigned int)                            licensemessage.o
    Iostream_init::Iostream_init(void)               msggen.o
    Iostream_init::~Iostream_init(void)               msggen.o
    istream::operator>>(char*)                    ../../../../libs/lib/libgeneral.a(string.o)
    setw(int)                          ../../../../libs/lib/libgeneral.a(string.o)
    unsafe_ostream::outstr(const char*, const char*)     ../../../../libs/lib/libgeneral.a(string.o)
    _ex_rethrow_q                       msggen.o
    ld: fatal: Symbol referencing errors. No output written to msggen
    gmake[3]: *** [msggen] Error 1

    Code:
    CC -ptv -L../../../libs/lib  -L../../../../../libs/lib  -L/u04/net/rtp-netapp1/vol/build/nwwls/devspace/thirdparty/SunOS/5.6/rwav/ver09.1/workspaces/SOLARIS26/SUNPRO42/0s/lib  -L/usr/ccs/lib  -L/opt/SUNWspro/prod/lib/CC4/libp main.o  TimeHarness.o versionString.o -xildoff  -nolib  -lperform  -lmodelGateWay  -lgateway  -lconfiguration  -lparser  -lexpressions  -lipc3  -lgeneral  -lrwextensions  -Bdynamic \
               /u04/net/rtp-netapp1/vol/build/nwwls/devspace/thirdparty/SunOS/5.6/rwav/ver09.1/workspaces/SOLARIS26/SUNPRO42/0s/lib/libora0s.a  /u04/net/rtp-netapp1/vol/build/nwwls/devspace/thirdparty/SunOS/5.6/rwav/ver09.1/workspaces/SOLARIS26/SUNPRO42/0s/lib/libdbt0s.a  /u04/net/rtp-netapp1/vol/build/nwwls/devspace/thirdparty/SunOS/5.6/rwav/ver09.1/workspaces/SOLARIS26/SUNPRO42/0s/lib/libtls0s.a  /u04/net/rtp-netapp1/vol/build/nwwls/devspace/thirdparty/SunOS/common/zlib-1.1.3/lib.sparc/libz.a  /u04/net/rtp-netapp1/vol/build/nwwls/devspace/thirdparty/SunOS/5.6/rwav/heap/lib/librwheap.a -lsocket  -lnsl  -lintl   -lgen   -Bstatic  -lC  -Bdynamic  -ldl  -Bstatic  -lcomplex  -lsunmath  -Bdynamic  -lthread  -lm  -lc  -nolib -o timeHarness|& c++filt
    Undefined                       first referenced
     symbol                             in file
    void __Cimpl::cplus_init()        (command line)
    _mcount                             /opt/SUNWspro/prod/lib/CC4/libp/libC.a(buffer.o)



    i am Migrating code from CC4.2 to CC5.8, I am using libraries and header files of CC5.8

    are above because of Those functions support not in CC5.8??
Page 1 of 2 12 Last
  • Jump to page:

IMN logo majestic logo threadwatch logo seochat tools logo