Results 1 to 6 of 6

Thread: va_start used in function with fixed args

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #5
    Join Date
    Sep 2006
    Posts
    27
    Thanks
    1
    Thanked 2 Times in 1 Post
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: va_start used in function with fixed args

    Quote Originally Posted by jacek View Post
    The easiest solution would be to move those last two parameters to the front, but I assume you can't do that, so instead you could change your InternalLogFunction() to something similar to qDebug() stream:
    didn't think about that. Wouldn't it require partly reinventing the printf mechanism?

    Suppose a case with 3 parameters:
    Log( "%d %s %d", 3, "test", 3, level, true );
    that would use
    InternalLogStream( iLevel, bLineEnd, Format ) << arg0 << arg1 << arg2;
    Each call to << should move on to the next '%' found in the format string, convert the argument, append result to internal string. That's what printf does..


    edit after thinking it through: it's really not a bad idea at all. It would require a call to 'Flush' or so after the InternalLogStream() calls because it has no way of knowing which argument is the last one, but I like the fact it uses templates: there's no way you can write a call with an argument that doesn't support conversion as the compiler would spot it immedeately so it's safer than normal printf. It might be somewhat slower though, still have to figure that out.
    Last edited by stinos; 27th November 2008 at 08:13.

Similar Threads

  1. QPSQL problem
    By LoneWolf in forum Installation and Deployment
    Replies: 60
    Last Post: 4th November 2009, 14:22
  2. QPSQL driver in windows
    By brevleq in forum Installation and Deployment
    Replies: 31
    Last Post: 14th December 2007, 12:57
  3. how to add static library into qmake
    By Namrata in forum Qt Tools
    Replies: 1
    Last Post: 20th November 2007, 17:33
  4. KDE/QWT doubt on debian sarge
    By hildebrand in forum KDE Forum
    Replies: 13
    Last Post: 25th April 2007, 06:13
  5. use qpsql
    By raphaelf in forum Installation and Deployment
    Replies: 34
    Last Post: 22nd August 2006, 12:52

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.