Results 1 to 14 of 14

Thread: typedef static const QString Tag;

  1. #1
    Join Date
    Jan 2006
    Location
    Kerala
    Posts
    371
    Thanks
    76
    Thanked 37 Times in 32 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default typedef static const QString Tag;

    What is wrong with
    Qt Code:
    1. typedef static const QString Tag;
    To copy to clipboard, switch view to plain text mode 

    is there a way around - using the #define
    We can't solve problems by using the same kind of thinking we used when we created them

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    85
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: typedef static const QString Tag;

    static in typedefs is illegal. You have to specify it at every definiton of a variable / member.

  3. #3
    Join Date
    Jan 2006
    Location
    Kerala
    Posts
    371
    Thanks
    76
    Thanked 37 Times in 32 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: typedef static const QString Tag;

    Quote Originally Posted by Codepoet
    static in typedefs is illegal. You have to specify it at every definiton of a variable / member.
    Or U can Use
    #define Tag static cosnt QString
    We can't solve problems by using the same kind of thinking we used when we created them

  4. #4
    Join Date
    Jan 2006
    Location
    Athens - Greece
    Posts
    219
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: typedef static const QString Tag;

    Quote Originally Posted by sunil.thaha
    Or U can Use
    #define Tag static cosnt QString
    Yes you can but please don't. It will just save you a few key strokes but you get all the evil things of preprocessor usage.

  5. #5
    Join Date
    Jan 2006
    Location
    Kerala
    Posts
    371
    Thanks
    76
    Thanked 37 Times in 32 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: typedef static const QString Tag;

    Quote Originally Posted by yop
    Yes you can but please don't. It will just save you a few key strokes but you get all the evil things of preprocessor usage.
    Like what. the whole Qt relies on preprocessors isn't ?
    We can't solve problems by using the same kind of thinking we used when we created them

  6. #6
    Join Date
    Jan 2006
    Location
    Athens - Greece
    Posts
    219
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: typedef static const QString Tag;

    Quote Originally Posted by sunil.thaha
    Like what. the whole Qt relies on preprocessors isn't ?
    I think you'll find this intresting (the whole faq is of great value). And could you give me an example of how Qt relies on the preprocessor.

  7. #7
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    85
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: typedef static const QString Tag;

    Qt uses several macros:
    Q_OBJECT, signals slots, foreach...
    foreach is a very bad one: Just try something like foreach(QPair<int, QString> p, c)... How many parameters has that "call"? 2? Not really...

  8. #8
    Join Date
    Jan 2006
    Location
    Athens - Greece
    Posts
    219
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: typedef static const QString Tag;

    Quote Originally Posted by Codepoet
    Qt uses several macros:
    Q_OBJECT, signals slots, foreach...
    foreach is a very bad one: Just try something like foreach(QPair<int, QString> p, c)... How many parameters has that "call"? 2? Not really...
    I bet you have used more than one gui APIs. I have a really hard time decrypting compile time errors due to macro expansions using them (but I've never passed the nwebie state in any of them so who knows maybe it's my fault ). Qt is the cleaner one when it comes down to that point (probably due to the meta compilation - moc). The most cryptic error I've encoutered is the vtable thingy, after that it's smooth. Maybe I'm just lucky... Do you agree on avoiding macros whenever possible?

  9. #9
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    85
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: typedef static const QString Tag;

    Try to avoid macros whereever possible. C++ misses some features so we need the preprocessor sometimes as in Qt.
    The best known exception to this rule are the include guards. Those you need, since #pragma once is bad and does not work like expected if you read the gcc docs...


    Offtopic:
    Say, around 9 years of C++ experience and several other languages. Much work with stl and boost and you learn how to decipher those compiler warnings
    It's not exactly right with the GUI APIs: long long ago WinAPI, then nothing (programmed internals without GUI) and since half a year Qt 4 after trying out wxwidgets and deciding that Qt 4 is better
    If you never encountered those messages which are several pages long you are really lucky - I should send you a sample the next time I hit one

  10. #10
    Join Date
    Jan 2006
    Location
    Athens - Greece
    Posts
    219
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: typedef static const QString Tag;

    Quote Originally Posted by Codepoet
    If you never encountered those messages which are several pages long you are really lucky - I should send you a sample the next time I hit one
    Not lucky, I'm just the ideal API client, I don't mess too much with it, I most probably will only subclass something at one level, I'm not doing much of inheritance, in general I don't consider myself an experienced developer, I'm in the state of the learning process were I'm trying to do everything by the book, (after having written many lines of nasty, ugly, evil code). To get past the rules you must firstly understand the rules I guess and that's why I'm here, share the little I know and above all learn. But it would be fun if I saw something like those messages you say, it's like taking a look at what comes next

  11. #11
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,013 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: typedef static const QString Tag;

    Hmm... what do you all want from C preprocessor? Almost all C programs rely on it and it is very helpfull when used properly. Qt heavily uses preprocessing too. All private data in Qt4 relies on preprocessing.

  12. #12
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 975 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: typedef static const QString Tag;

    Quote Originally Posted by wysota
    what do you all want from C preprocessor?
    It doesn't check whether argument types are correct, using expressions as parameters isn't safe, it may create vast amounts of weird error messages while the problem is only in one place, and so on.

    Of course macros can be useful, iff used in a correct way.

  13. #13
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,013 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: typedef static const QString Tag;

    Quote Originally Posted by jacek
    Of course macros can be useful, iff used in a correct way.
    You can say that about almost everything...

  14. #14
    Join Date
    Jan 2006
    Location
    Athens - Greece
    Posts
    219
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: typedef static const QString Tag;

    I am trying hardly to get rid of them but that is not completely possible. Anyway whenever I find it absolutely necessery to use one I make all of my colleagues read it and warn me about possible problems. I guess I'm too afraid of them

Similar Threads

  1. shared vs static
    By alisami in forum Installation and Deployment
    Replies: 3
    Last Post: 4th October 2008, 13:04
  2. Replies: 16
    Last Post: 23rd May 2008, 10:12
  3. qt 4.2.2 install in tru64 cxx
    By try to remember in forum Installation and Deployment
    Replies: 0
    Last Post: 30th March 2007, 07:43
  4. Convert from iso-8859-1 to... Something else :-)
    By Nyphel in forum Qt Programming
    Replies: 4
    Last Post: 7th March 2007, 17:59
  5. QTableView paints too much
    By Jimmy2775 in forum Qt Programming
    Replies: 2
    Last Post: 26th July 2006, 18:42

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.