Results 1 to 2 of 2

Thread: default vaules in Slice

  1. #1
    denn is offline Registered User
    Name: Denn Sporcic
    Organization: L3 Nautronix
    Project: Great Barrier Reef Vessel Tracking System
    Join Date
    May 2009
    Posts
    15

    default vaules in Slice

    Hi Guys,

    Testing my code with Ice 3.4.2 and noticed a change in generated code with regards to initializer lists in C++.

    It's to do with float default values.
    Example SLICE

    class aClass
    {
    float a = 0.0;
    float b = 1.1;
    double c = 0.0;
    double d = 1.1;
    };

    This used to generate

    ::aClass::aClass() :
    a(0),
    b(1.1),
    c(0),
    d(1.1)

    Now it generates

    ::aClass::aClass() :
    a(0F),
    b(1.1F),
    c(0),
    d(1.1)

    GCC and Visual Studio is now complaining about variable 'a' with an invalid suffix 'F'.

    Having 'F' is more correct, however the parser should not be truncating default values for floats and doubles.

    (float a = 0F) != (float a = 0.0F)

    My only work around is not to set a default value of 0.0 anymore. Or hack the cpp/src/slice2cpp/Gen.cpp line 107 and remove the 'F' suffix.


    VERY annoying..!

    cheers
    Denn

  2. #2
    xdm's Avatar
    xdm
    xdm is offline ZeroC Staff
    Name: Jose Gutierrez de la Concha
    Organization: ZeroC, Inc.
    Project: Ice Developer
    Join Date
    Sep 2003
    Location
    La Coruņa, Spain
    Posts
    588
    Hi Deen

    as a workaround you can use a const int:
    Code:
    const int zeroI = 0;
    
    struct s
    {
       float x = zeroI;
    }
    Thanks for report the bug, we will fix this in the next Ice release

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. How to know what default things are?
    By Pompei2 in forum Help Center
    Replies: 6
    Last Post: 09-12-2009, 09:09 AM
  2. About default servants...
    By Yos in forum Help Center
    Replies: 1
    Last Post: 08-03-2009, 06:37 AM
  3. Replies: 2
    Last Post: 03-03-2008, 11:10 PM
  4. a problem about the default template
    By rwxybh in forum Help Center
    Replies: 2
    Last Post: 12-28-2005, 03:33 AM
  5. Documentation for Default Servants example
    By andreynech in forum Bug Reports
    Replies: 2
    Last Post: 09-24-2003, 07:59 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •