Administrators Jon Posted December 17, 2003 Administrators 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/
Valik Posted December 17, 2003 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
Administrators Jon Posted December 17, 2003 Author Administrators 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/
Administrators Jon Posted December 17, 2003 Author Administrators 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/
Valik Posted December 17, 2003 Posted December 17, 2003 I love stupid bugs like that. They're what makes programming worth killing yourself over.
Administrators Jon Posted December 17, 2003 Author Administrators 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/
jpm Posted December 18, 2003 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
Administrators Jon Posted December 18, 2003 Author Administrators 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/
spt Posted January 9, 2004 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 ~~
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now