Join Now

Hi, I'm Paul, but you can also call me Todd and I won't get upset.

How bust is TVersion?

Paul.Todd | 04 April, 2008 21:47

This little structure is useful for communicating version information.
Amongst things, it is used to check the client and the server versions are compatible as well as being used as part of the sis installer versioning

Now what will the following print?

const TVersion ver(192,278,20070403);
RDebug::Printf(_L("%d.%d.%d"), ver.iMajor, ver.iMinor, ver.iBuild);

Well the result is "-64.22.16387" but why does this happen?


Lets look at the class declaration:

class TVersion
    {
public:
    IMPORT_C TVersion();
    IMPORT_C TVersion(TInt aMajor,TInt aMinor,TInt aBuild);
    IMPORT_C TVersionName Name() const;
public:
    TInt8 iMajor;
    TInt8 iMinor;
    TInt16 iBuild;
    };

 The fields are stored as 1 and 2 byte values but the constructor takes an int. So if you have version number that is greater than 255 or a build number greater than 32767 the compiler will silently truncate the value down to a smaller value.

Whilst this is annoying, in the FP2 SDK, the makesis code checks the ranges and maks sure they will fit, if the don't then the makesis program exists without building a sis file.

So beware, in at least FP2 make sure your build numbers fit inside a version structure!

Comments

Re: How bust is TVersion?

symbianyucca | 05/04/2008, 09:55

There are other variables which you need to cast to unsigned before using, for exmaple TUid's iUid is also signed integer, thus any 0xAxxxx, will show as negative number unless you cast it to unsigned before printing..

You must login to post comments. Login
 
 
Powered by LifeType
     
     RDF Facets:
     
     
     qfnZtopicQUqfnTopicZcppQ
     qfnZtopicQUqfnTopicZseriesE5f60Q
     qfnZtypeQUqfnTypeZBlogContentQ
     qfnZtypeQUqfnTypeZBlogE45ntryQ
     qfnZtypeQUqfnTypeZCommunityContentQ
     qfnZtypeQUqfnTypeZWebpageQ
     qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX