Archived

This forum has been archived. Please start a new discussion on GitHub.

slice generated classess in c++ and unused parameters

xdm
xdm La Coruña, Spain
Hi

when i compile c++ classes generated with slice2cpp i get a lot of warnings like this

g++ -c -pipe -Wall -W -O2 -march=pentium4 -D_REENTRANT -fPIC  -DQT_NO_DEBUG -DQT_THREAD_SUPPORT -I/usr/qt/3/mkspecs/linux-g++ -I. -I/opt/Ice-3.0.1/include -I../../include -I/usr/qt/3/include -o .obj/CmsSite.o ../../src/Cms/CmsSite.cpp
../../src/Cms/CmsSite.cpp: In member function `IceInternal::DispatchStatus
   Oz::Cms::CmsSiteClient::___initialize(IceInternal::Incoming&, const
   Ice::Current&)':
../../src/Cms/CmsSite.cpp:2549: warning: unused parameter `
   IceInternal::Incoming&__inS'
../../src/Cms/CmsSite.cpp: In member function `Oz::Cms::CmsSite::CmsSite(const
   Oz::Base::Keys&, const Oz::Base::OnRezPrx&, const
   Oz::Base::OnRezServicePrx&, const IceStorm::TopicPrx&, const
   Oz::Base::TopicsMap&, const Ice::Identity&, const Oz::Base::AclPrx&, long
   long int, const Oz::Base::ComentIdMap&, const Oz::Base::ComentNumberMap&,
   bool, const std::string&, const Oz::Base::StringMap&, const
   Oz::Base::StringMap&, const Oz::Files::FileSystemPrx&, const
   Oz::Domains::DomainPrx&, const Oz::Domains::GroupPrx&, const
   Oz::Domains::GroupPrx&, const Oz::Domains::GroupPrx&, const
   Oz::Domains::GroupPrx&, const std::string&, const Oz::Cms::StringLocaleMap&,
   const Oz::Mail::MailAcountPrx&, const Oz::Cms::ConfirmationMailPrx&, const
   Oz::Cms::UserProfileMap&, const Oz::Cms::AcountDataMap&, const
   Oz::Files::DocumentPrx&)':
../../src/Cms/CmsSite.cpp:3049: warning: unused parameter `const

a linux box with gcc-3.3.6 / Ice-3.0.1

is this normal? any tip for avoid this warnings?

Comments

  • bernard
    bernard Jupiter, FL
    Hi Jose,

    Could you post the corresponding Slice definitions?

    Thanks,
    Bernard
  • xdm
    xdm La Coruña, Spain
    slices

    I atach a file with slices you must reaname it as tar.bz2

    and extract with tar jxf

    the warning of previous Post is form Cms/CmsSite.ice generated files but this ocurr with more.

    thanks
  • matthew
    matthew NL, Canada
    You are getting these warnings because the -W flag enabled -Wunused-parameter which warns about unused parameters to methods. Currently there is no way to generate slice code which will not warn if you have this warning enabled. The simplest method to avoid this warning is to avoid using -W when compiling the generated code.

    We will look into avoiding this warning in a future Ice version. Should you have a more urgent commercial need please contact us at sales@zeroc.com.
  • matthew
    matthew NL, Canada
    BTW, your use of idempotent in your interface definitions looks to me to be wrong.

    For example, in Mail/Email.ice I see:
                            idempotent void
                            send();
    

    Now, I'm not sure exactly what this does, but assuming it sends an email the use of idempotent in this case would most likely be incorrect. The definition from the Ice manual is as follows:
    An idempotent operation is an operation that, if executed twice, has the same effect as if executed once.

    If you mark a method as idempotent the Ice runtime code could call the same method more than once. I assume that executing send twice will send the same email twice, which isn't the same thing as sending it once :)

    Of course, its possible that I don't understand your interfaces or implementation -- but I thought I should point this out.
  • xdm
    xdm La Coruña, Spain
    I know that -W enable this warning and i use it for this reason only send this report to know if is normal to have a lot of unused parameters in the slice generated code.
  • matthew
    matthew NL, Canada
    It doesn't indicate a bug, if that's what you mean. For example, if you compile the hello generated code you get this:
    Hello.cpp: In member function `IceInternal::DispatchStatus 
       Demo::Hello::___sayHello(IceInternal::Incoming&, const Ice::Current&) const
       ':
    Hello.cpp:329: warning: unused parameter `IceInternal::Incoming&__inS'
    

    Looking at the generated code you can see:
    ::IceInternal::DispatchStatus
    Demo::Hello::___sayHello(::IceInternal::Incoming& __inS, const ::Ice::Current& __current) const
    {
        __checkMode(::Ice::Nonmutating, __current.mode);
        sayHello(__current);
        return ::IceInternal::DispatchOK;
    }
    
    This method is used for the server side dispatch of a method invocation. Since there are no in or out arguments the __inS parameter is not used.

    This does not represent an error.