×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Feb 2005
    Location
    Turkey & Finland
    Posts
    42

    Weird Behaviour in Printf

    Hello,
    I have 2 questions. I had this line in my code:

    Code:
    // Globals
    TInt		iBytes = 0;
    TInt		iFiles = 0;
    TInt		iFolders = 0;
    ...
    void function f()
    {
    ...
    console->Printf(_L("%f bytes (%d folders and %d files) copied\n"), iBytes, iFolders, iFiles);
    ...
    }
    In the debugger at this line, all 3 variables have some non-zero values let's say X,Y,Z.
    This code prints :
    "0.0000 bytes (Y folders and 0 files) copied".

    But when I change the line to

    Code:
    console->Printf(_L("%d bytes (%d folders and %d files) copied\n"), iBytes, iFolders, iFiles);
    (i.e. change %f to %d)This code prints:
    "X bytes (Y folders and Z files) copied"

    So I am curious about this behaviour in the first code. Why it is so(i.e iBytes does not work that's ok,but why iFolders works and not iFiles)?

    And second question, how can I see the implementation of the Printf(i.e. where is e32cons.cpp)? VC++ 6 shows only e32cons.h file.

    Thanks in advance for your responses.

    --------------------------------------------------------------------------------
    CaNeR
    Last edited by LAS__VEGAS; 2005-02-25 at 10:39.

  2. #2
    Registered User
    Join Date
    Feb 2005
    Location
    Turkey & Finland
    Posts
    42
    OK, I figured out answer of my first question.

    TReal is 8 bytes, TInt is 4 bytes. So printf first tries to insert a float and fetches 8 bytes(i.e. tries to print X + Y) and it is not a valid float so it prints 0. Then it fetches next 4 bytes(range 9-12 where Z is located) , to insert Y. Then it fetches Z (range 13-16 , it is garbage) and prints 0.

    The bad luck here is that in my test case Y was equal to Z. So I thought it prints Y correctly and not Z. where in reality it was printing Z as Y.

    My 2nd question is still valid though, can I see the source code of Symbian SDK?
    --------------------------------------------------------------------------------
    CaNeR

  3. #3
    Super Contributor
    Join Date
    Nov 2004
    Location
    Wiltshire, UK
    Posts
    3,644
    You will need to purchase the DevKit from Symbian for the Source Code for Symbian

    By the way I don't know what devices you are targetting but generally writeable static data data like you have is not supported when build for ARM processors on Symbian. The exception being a .exe (console app)

Posting Permissions

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