Jon 1,009 Posted December 17, 2003 Can anyone see why this would work: MessageBox(NULL, vParams[0].szValue(), "", MB_OK); but this doesn't: const char *szValue = vParams[0].szValue(); MessageBox(NULL, szValue, "", MB_OK); Given that .szValue() returns "const char *" :iamstupid: Deployment Blog: https://www.autoitconsulting.com/site/blog/ SCCM SDK Programming: https://www.autoitconsulting.com/site/sccm-sdk/ Share this post Link to post Share on other sites
Valik 478 Posted December 17, 2003 (edited) Very strange. I say blame Microsoft just because it's fun. Have you re-written any of the Variant or VectorVariant code since 3.0.76? That's the last copy of the source I have downloaded so it's the one I looked at. Using it for reference, I see no reason why that code won't work (For what my opinions worth, I probably have less programming experience than all of you). Could it maybe have something to do with the subscripting operator? I threw together a simple class where a function returned a const char* to a dynamically allocated array and I experienced no abnormalities. The only thing I didn't test was subscripting. :: shrugs :: :iamstupid: :iamstupid: Edited December 17, 2003 by Valik Share this post Link to post Share on other sites
Jon 1,009 Posted December 17, 2003 Hmm, I thought it was odd too so am just trying to work out if it's like you say a subscript bug. This works, so it looks like the variant creation, assignment and copy constructors are working ok: const char *pszValue; Variant vTest; vTest = "Hello"; MessageBox(NULL, vTest.szValue(), "", MB_OK); pszValue = vTest.szValue(); MessageBox(NULL, pszValue, "", MB_OK); Variant vTestCopy(vTest); MessageBox(NULL, vTestCopy.szValue(), "", MB_OK); pszValue = vTestCopy.szValue(); MessageBox(NULL, pszValue, "", MB_OK); vTestCopy = vTest; MessageBox(NULL, vTestCopy.szValue(), "", MB_OK); pszValue = vTestCopy.szValue(); MessageBox(NULL, pszValue, "", MB_OK); Deployment Blog: https://www.autoitconsulting.com/site/blog/ SCCM SDK Programming: https://www.autoitconsulting.com/site/sccm-sdk/ Share this post Link to post Share on other sites
Jon 1,009 Posted December 17, 2003 Bah, I see it. Look at the declaration of the subscript in vectorvariant: Variant operator[](unsigned int nIndex); // Overloaded [] Deployment Blog: https://www.autoitconsulting.com/site/blog/ SCCM SDK Programming: https://www.autoitconsulting.com/site/sccm-sdk/ Share this post Link to post Share on other sites
Valik 478 Posted December 17, 2003 I love stupid bugs like that. They're what makes programming worth killing yourself over. Share this post Link to post Share on other sites
Jon 1,009 Posted December 17, 2003 All my stacks, vectors, tokens everything had the same declaration, and while not technically a bug I'm now returning references everywhere instead of these temporary "copies". Result: - Everything is faster (less copying) - Uncompressed EXE reduced by 30KB! (78KB compressed) - All vectors can be modifed as well as just read: e.g. vParams[0] = ... This is one of those times I realise how complicated C++ can be... Deployment Blog: https://www.autoitconsulting.com/site/blog/ SCCM SDK Programming: https://www.autoitconsulting.com/site/sccm-sdk/ Share this post Link to post Share on other sites
jpm 93 Posted December 18, 2003 I am wondering why only m_nNull dummy is initialize and not the m_sNull, m_vNull. is the value never used? only the reference Share this post Link to post Share on other sites
Jon 1,009 Posted December 18, 2003 It's never used. And the Variant (unlike an integer) sets itself up with a valid value when it is created. Deployment Blog: https://www.autoitconsulting.com/site/blog/ SCCM SDK Programming: https://www.autoitconsulting.com/site/sccm-sdk/ Share this post Link to post Share on other sites
spt 0 Posted January 9, 2004 if it dont work, tinker with it a bit, and maybe then it will work lol either that or give bill gates a call ~~ Safeguarding The Land ~~ Share this post Link to post Share on other sites