C BSFN Incompatible types.

Gary P

Active Member
Hi,

I'm making some enhancements on an existing business function that will parse tokens from a file and replace them with strings. But I'm getting some problems.

Here is the relevant code:

<font class="small">Code:</font><hr /><pre>
while ((tokenptr=myStrStr(curptr,"LABELTOKEN",bytesread-(tokenptr-buffer)))>'\0')
{
/* Once we find a token, we want to copy everything
to the left of the token to the output, if it has not yet been copied. */
memcpy(outptr, curptr, tokenptr-curptr);
outptr += (tokenptr-curptr);
memcpy(outptr,lpDS->szLabelToken,strlen(lpDS->szLabelToken));
curptr = tokenptr+strlen("LABELTOKEN");
outptr += strlen(lpDS->szLabelToken);
}
</pre><hr />

All the pointers are type char *, and here is the header to the custom function called:

<font class="small">Code:</font><hr /><pre>
static char * MyStrStr(const char *s1, const char *s2, const long bufferlen)
</pre><hr />

One more, here is a section of code that works just fine:

<font class="small">Code:</font><hr /><pre>
while ((tokenptr=MyStrStr(curptr,MyToken[x],bytesread-(tokenptr-buffer)))>'\0')
{
memcpy(outptr, curptr, tokenptr-curptr);
outptr += (tokenptr-curptr);
memcpy(outptr,JCHARToChar(UserReservedAlpha),jdeStrlen(UserReservedAlpha)); </pre><hr />

The above seems to work just fine. However, when I try to build the BSFN in JDE, here's what I get:

<font class="small">Code:</font><hr /><pre>
c:\e810\DV810\source\B550006.c(467) : warning C4133: 'function' : incompatible types - from 'char *' to 'unsigned short *'
c:\e810\DV810\source\B550006.c(467) : warning C4133: 'function' : incompatible types - from 'char [11]' to 'unsigned short *'
c:\e810\DV810\source\B550006.c(467) : warning C4133: '=' : incompatible types - from 'unsigned short *' to 'char *'
c:\e810\DV810\source\B550006.c(472) : warning C4133: 'function' : incompatible types - from 'unsigned short [33]' to 'const char *'
c:\e810\DV810\source\B550006.c(474) : warning C4133: 'function' : incompatible types - from 'unsigned short [33]' to 'const char *'
</pre><hr />

Line 467 is where my first block of code begins.

I'm really confused to this, as I don't know why it's considering unsigned short *, unless there was some implicit conversion that's messing it up.

Any help you can offer would be appreciated. Thanks!
 
First of all, it's hard to decipher your errors when we can't tell what line# is associated with each of your posted lines of code.

I'm assuming you did a copy/paste to get your code in. A couple of things I notice:
1 - your first call to MyStrStr has an issue with case sensitivity (unless it is just a typo on this post)
2 - I notice you're on 810...That means all jde strings (ie: in your lpDS) will be unicode strings, so you should always use the jdeStrxxx equivalent of all the string functions. You have used strlen with lpDS string values which will be an issue...use jdeStrlen.

JCHAR is defined as unsigned short. So all JDE strings beginning with B9 are defined as unsigned short *.
 
You're completely right - I realized it yesterday but couldn't say so because my post hadn't been approved. I was using the wrong case, so I was calling a unicode version of the function I mentioned. And I fixed the strlen functions by just using a JCHARToChar function, though jdestrlen would have worked as well.

Sorry about the line numbers, I meant to say that the first line in the original code I posted was the first line referred to in the debug log.

Thanks for your help though. Changing the case and converting from JCHAR * to char * fixed the problems.
 
Seems like you are converting from const char to char * normal character array. Try to use same types in prototype and variables.

Chan
 
Back
Top