Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 811
Default XLL - VS .Net2003 - init problem - const char strings - /Gf option??

Hi Kevin,

One idea, make sure that your nFuncs array is declared similar to the
following:

#define NUM_FUNCS 5
#define NUM_ARGS 9
#define MAX_LENGTH 255

static char nFuncs[NUM_FUNCS][NUM_ARGS][MAX_LENGTH] =
{
// function table array
};

instead of like this:

#define NUM_FUNCS 5
#define NUM_ARGS 9

static char nFuncs[NUM_FUNCS][NUM_ARGS] =
{
// function table array
};

The latter example was the method demonstrated in the XLL framework provided
with the Excel SDK, but it's an invalid construct in this context. You can't
add byte counts to the strings in this array later on because writing to
string literals is undefined. It works when compiled as a C project in VC6,
but that's just pure luck.

--
Rob Bovey, MCSE, MCSD, Excel MVP
Application Professionals
http://www.appspro.com/

* Please post all replies to this newsgroup *
* I delete all unsolicited e-mail responses *


"Kevin Love" wrote in message
...[i]

Trying to port large .xll project to VS .Net 2003.
Failing to load add-in.

problem seems to be due to inability of compiler to
read/write strings.

compiled using compiler flag /Gf, get warning message

c1xx : warning C4349: /Gf is deprecated and will not be
supported in future versions of Visual C++; remove /Gf or
use /GF instead

#######################

Downloaded Anewxll project from msdn web site - same
problem. Xll refuses to run - crashes on init
in the following code.

for(nFuncs=0; func[nFuncs][0]; nFuncs++) {
for(i=0; i<9; i++) {
func[nFuncs][i][0] = (BYTE) strlen(func[nFuncs]
+1);
}
}

####################

Any ideas appreciated.

Kevin Love



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 811
Default XLL - VS .Net2003 - init problem - const char strings - /Gf option??

Hi Kevin,

Unfortunately, no. That example was just a really glaring mistake in the
SDK. Writing to string literals in this manner worked in some configurations
in earlier versions of VC++, maybe because they happened to get stored in
writable memory. But whatever allowed this to work, it seems to have been
fixed in VC.NET. Since it's undefined behavior according to the standard,
there isn't any way to make it work again.

--
Rob Bovey, MCSE, MCSD, Excel MVP
Application Professionals
http://www.appspro.com/

* Please post all replies to this newsgroup *
* I delete all unsolicited e-mail responses *


"Kevin Love" wrote in message
...

Thanks for solution above. It definitely seems
to do the trick with writing to string literals.
At least I got over the initial hurdle. Now I have
a bunch of code that looks like this that is crashing.
Any ideas, other than just slugging thru it all
and changing it to enable string literal writing?


static char* xll_name_buf = " my excel string.";
xInfo.xltype = xltypeStr;
xInfo.val.str = xll_name_buf;
xInfo.val.str[0] = lstrlen(&xll_name_buf[1]);



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Init Caps msnyc07 Excel Worksheet Functions 3 December 27th 09 09:19 PM
Formula to check for Init Caps (not just 'Proper') msnyc07 Excel Discussion (Misc queries) 1 December 15th 09 07:54 AM
Conditional format to highlight only cells with formula, not const hkbarnett Excel Worksheet Functions 2 November 19th 09 01:49 AM
option to add asterisk indicating statistical signficance in char. [email protected] Charts and Charting in Excel 1 May 19th 06 01:24 PM
8500 cells with phone number(7 char.), wishing to add area code (10 char.) [email protected] Excel Discussion (Misc queries) 6 March 10th 06 05:13 PM


All times are GMT +1. The time now is 07:00 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"