What is wrong with
Qt Code:
To copy to clipboard, switch view to plain text mode
is there a way around - using the #define
What is wrong with
Qt Code:
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
static in typedefs is illegal. You have to specify it at every definiton of a variable / member.
Or U can UseOriginally Posted by Codepoet
#define Tag static cosnt QString
We can't solve problems by using the same kind of thinking we used when we created them
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.Originally Posted by sunil.thaha
Like what. the whole Qt relies on preprocessors isn't ?Originally Posted by yop
We can't solve problems by using the same kind of thinking we used when we created them
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.Originally Posted by sunil.thaha
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?Originally Posted by Codepoet
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
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 nextOriginally Posted by Codepoet
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.
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.Originally Posted by wysota
Of course macros can be useful, iff used in a correct way.
You can say that about almost everything...Originally Posted by jacek
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
Bookmarks