C++ Template Question
Adriaan de Groot
groot at kde.org
Thu Aug 23 00:05:33 BST 2007
On Thursday 23 August 2007 00:24:11 Olivier Goffart wrote:
> Le lundi 20 août 2007, Mosfet a écrit :
> > http://doc.trolltech.com/4.3/qvarlengtharray.html
>
> int myfunc(int n)
> {
> int table[n + 1]; // WRONG
Very much wrong indeed.
> This works fine with GCC (unless you use --pedantic)
> It's a nice gnu extention.
> Does it works with others compiler supported by KDE?
Nope. At least one doesn't like it.
> allow arrays dynamically on the stack if the compiler is GCC, and use
> QVarLengthArray otherwise? Would that be worth?
You would have be be quite careful that *everything* you do is portable on
both sides; I can imagine weird cases like returning pointers to elements or
returning the entire array that might work on the QVarLengthArray and not on
the GCC-istic variable length array.
--
KDE Quality Team http://www.englishbreakfastnetwork.org/
GPG: FEA2 A3FE http://people.fruitsalad.org/adridg/
"It is impossible to make an emphatic point with only two arms."
More information about the kde-core-devel
mailing list