Re: Trouble getting QuantLibAddin to work with vc 7.1
Posted by
eric ehlers on
May 18, 2005; 7:41am
URL: http://quantlib.414.s1.nabble.com/Trouble-getting-QuantLibAddin-to-work-with-vc-7-1-tp10802p10807.html
On 5/18/05, Plamen Neykov <
[hidden email]> wrote:
>
> Hi Eric,
>
> I've took a look where the TempStr function is used - it comes predominantely
> in the generated code - qladdin.cpp, I found only one reference elsewhere -
> in the file xlutils.cpp. I think the python generaton procedure could be
> easily changed in the way to generate in the first byte of a string literal
> the size of it directly so that this doesn't have to be done run-time - I
> could try to change it - what do you think?
>
> Thanks,
> Plamen
Hi Plamen,
Here's a revised TempStr function which should do the trick:
LPXLOPER TempStr(LPSTR lpstr)
{
LPXLOPER lpx;
lpx = (LPXLOPER) GetTempMemory(sizeof(XLOPER));
if (!lpx)
{
return 0;
}
/*
lpstr[0] = (BYTE) lstrlen (lpstr+1);
lpx->xltype = xltypeStr;
// lpx->val.str = (PUCHAR) lpstr;
lpx->val.str = lpstr;
*/
int len = strlen(lpstr);
lpx->xltype = xltypeStr;
lpx->val.str = GetTempMemory(len);
if (!lpx->val.str) return 0;
strncpy(lpx->val.str, lpstr, len);
lpx->val.str[0] = (BYTE) len-1;
return lpx;
}
But your proposed solution is much preferable:
- faster
- no risk of exceeding available temp memory
- no VC7-specific hack
so if you're happy to implement that it would be hugely appreciated.
Regards,
Eric