Results 1 to 8 of 8

Thread: Transform a QVector / QStringList in a va_list

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Sep 2011
    Posts
    1,241
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    3
    Thanked 127 Times in 126 Posts

    Default Re: Transform a QVector / QStringList in a va_list

    lol, second time in two days I see a C lover call C++ ugly! C++ is much prettier than C imo. va_list is inherently unsafe as there is no type checking, so you should not worry about the same issue in your macros. Generally this is a problem throughout C! Your PM sounds like a douche. If you are using Qt, then there is already a C++ 'bottleneck', so why stick to C?

    The best way is to expose
    Qt Code:
    1. void messagebox(json_object **json, char *iconType, char *title, char *msg, int showTime, va_list ap)
    To copy to clipboard, switch view to plain text mode 
    so that you can make your own va_list and pass into this method. Without this available, you only have hack solutions, I think.
    Last edited by amleto; 20th April 2013 at 13:01.
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

  2. #2
    Join Date
    Apr 2013
    Location
    milan
    Posts
    13
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Transform a QVector / QStringList in a va_list

    Quote Originally Posted by amleto View Post
    lol, second time in two days I see a C lover call C++ ugly! C++ is much prettier than C imo. va_list is inherently unsafe as there is no type checking, so you should not worry about the same issue in your macros. Generally this is a problem throughout C! Your PM sounds like a douche. If you are using Qt, then there is already a C++ 'bottleneck', so why stick to C?
    I think in the same way C++ is better than C overloading, inheritance, GUI toolkits (as our friend Qt), event driven programming... the only thing that C++ did wrong is, IMHO, that could be, for someone, one of its point of force the C compatibility why:

    1. All the pointers things are unsafe!
    2. The C compatibly is not complete, too... an essential C keyword called NULL is not present (it calls it "0"), and an empty variable doesn't evaluates to false
    3. Code that C compiles perfectly or giving only a warning doesn't compile in C++ !


    We maybe you could hate me but I, personally, prefer the Java approach all is object (well not completely to be honest int is primitive variable Int is the object), no pointer and no compatibility with the old, ugly (it is that beast that is ugly not Qt/C++) and unsafe C.

    By the way yes va_args are unsafe __builtin_va_arg_pack() tries to mitigate the problem as at least permits to check the size of the args without the need to use a variable or a NULL in the end but yes if I pass an int instead of char * the code would compile and, probably will crash when it will try to convert to a char *!

    In the end if I don't have done nothing wrong and there's a bug in __builtin_va_arg_pack() when called by a function that calls again __builtin_va_arg_pack() I go for a hibryd approach: I'll implement the info(), warning(), alert(), wait() as variadic macro that will call the messagebox function... but I hate the macro syntax in particular when I have to write functions like macros

    Quote Originally Posted by amleto View Post
    The best way is to expose
    Qt Code:
    1. void messagebox(json_object **json, char *iconType, char *title, char *msg, int showTime, va_list ap)
    To copy to clipboard, switch view to plain text mode 
    so that you can make your own va_list and pass into this method. Without this available, you only have hack solutions, I think.
    By the way the hack is in test code so not problem but the curiosity remains is possible to use the Meta Object Compiler to create your own code?
    I could use him to make a switch for example? Maybe in the future I could find a good usage of this technique...

  3. #3
    Join Date
    Sep 2011
    Posts
    1,241
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    3
    Thanked 127 Times in 126 Posts

    Default Re: Transform a QVector / QStringList in a va_list

    what would be the point in using moc to generate code? your problem is still a run-time problem, so moc can't help you there...
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

  4. #4
    Join Date
    Apr 2013
    Location
    milan
    Posts
    13
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Transform a QVector / QStringList in a va_list

    See my fist post I wanted MOC to help me to write at least the first 32 version of the switch()... is this possible?

    It is in general possible to make MOC create custom code?

  5. #5
    Join Date
    Sep 2011
    Posts
    1,241
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    3
    Thanked 127 Times in 126 Posts

    Default Re: Transform a QVector / QStringList in a va_list

    no, I don't think so. Just write it by hand - it's going to look ugly whether you do it or moc does it (if it could).
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

Similar Threads

  1. sort a Qvector based on another Qvector
    By OzQTNoob in forum Qt Programming
    Replies: 2
    Last Post: 16th February 2012, 06:39
  2. Replies: 5
    Last Post: 2nd September 2011, 23:11
  3. Need to create QStringList and QVector in FORTRAN
    By praveen in forum Qt Programming
    Replies: 4
    Last Post: 3rd April 2008, 15:20
  4. Bring va_list args; to a QStringList or a qmap
    By patrik08 in forum General Programming
    Replies: 8
    Last Post: 18th June 2006, 12:31
  5. Replies: 7
    Last Post: 2nd June 2006, 12:48

Tags for this Thread

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.