Q_GLOBAL_STATIC

Harald Fernengel harry at kdevelop.org
Tue Sep 20 21:06:41 BST 2005


Hi,

On Tuesday 20 September 2005 12:50, Thomas Braxton wrote:
> Looking at KAuthorized I noticed the use of Q_GLOBAL_STATIC, would the
> usage of Q_GLOBAL_STATIC be desired for other classes that only contain
> static public functions with hidden static data?
> Attatched is a patch to kcrash.cpp that changes usage of all statics
> through a hidden class. Ok to commit?

please don't. Q_GLOBAL_STATIC is only for non-pod data (classes that have a 
constructor). The static bools, char *, ints in kcrash are all PODs, so 
there's absolutely no reason to wrap them into a Q_GLOBAL_STATIC.

static char *foo = "something"; // perfectly legal
static MyStruct m = {1, 2, 3}; // also legal
static QString bar; // funny crashes when used in a library

Harald




More information about the kde-core-devel mailing list