473,395 Members | 1,856 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

casting pointer data type -more info

Hi,
I have a third party function that has a following signature:
function(char * memoryBuffer, long bufferSize);
I want to following Base64::decode() from Apache's XML C++ APIs:
XMLByte* Base64::decode ( const XMLByte *const inputData,
unsigned int * outputLength,
MemoryManager *const memMgr = 0
)
The problem is that the decode() returns a diff type XMLByte* defined
as unsinged char and an unsigned int for outputLength in decode()
above, those two values that I like to past them to the the third
party function, but cannot pass C++ compiler due to the mismatched
data types if I use static_cast.
I hate to directly cast them to char* from XMLByte and unsigned int to
long using C type casting, what is the best portable way to resolve
this?
Thanks.
Jul 22 '05 #1
1 1693
On Wed, 07 Jan 2004 06:53:56 -0800, wenmang wrote:
Hi,
I have a third party function that has a following signature:
function(char * memoryBuffer, long bufferSize);
I want to following Base64::decode() from Apache's XML C++ APIs:
XMLByte* Base64::decode ( const XMLByte *const inputData,
unsigned int * outputLength,
MemoryManager *const memMgr = 0
)
The problem is that the decode() returns a diff type XMLByte* defined
as unsinged char and an unsigned int for outputLength in decode()
above, those two values that I like to past them to the the third
party function, but cannot pass C++ compiler due to the mismatched
data types if I use static_cast.
I hate to directly cast them to char* from XMLByte and unsigned int to
long using C type casting, what is the best portable way to resolve
this?


What is an XMLByte? If it is another way of saying one of the char types,
then the cast to char* would be okay, but you have to use reinterpret
cast. Beware that it may be a character type, but the contents of the
buffer may not be ordinary text, it could be UTF8 f.i.

Casting an unsigned int to a long is fine, however I think you ment
unsigned int* to long*. That is not good, they are funcdamentaly
different. You'll have to allocate an array of longs, copy the unsigned
ints over into this new array and pass the new array to the 3rd party api.

HTH,
M4

Jul 22 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Jacob Jensen | last post by:
This question has probably been asked a million time, but here it comes again. I want to learn the difference between the three type cast operators: static_cast, reinterpret_cast, dynamic_cast. A...
16
by: He Shiming | last post by:
Hi, I'm having a little bit of trouble regarding pointer casting in my program. I don't understand why the following two cases produce different results. Case 1: IInterface *pInterface = new...
231
by: Brian Blais | last post by:
Hello, I saw on a couple of recent posts people saying that casting the return value of malloc is bad, like: d=(double *) malloc(50*sizeof(double)); why is this bad? I had always thought...
1
by: rahul8143 | last post by:
hello, In kernel source code there is ip_fragment.c file my question is regarding pointer function and casting for that look at required snippet from that file There is structure defined for...
25
by: hugo2 | last post by:
Obrhy/hugo July 12, 2004 Take a look at this memcpy() definition. Is there a good reason the void pointer args are cast to byte just to assign their addresses to byte pointers? /*from Steve...
14
by: Mirko | last post by:
Hello, I'm new to this list and to Usenet in general, so please forgive (and advice) me, if I do something wrong. Anyway. I am a bit confused, because I always thought one _should_ explicitly...
8
by: Michael | last post by:
Hi, I think my problem deals with class casting and inheritance. I want to deal with various Audio Formats, reading into memory for modification, working with it (done by different classes),...
33
by: Mark P | last post by:
A colleague asked me something along the lines of the following today. For some type X he has: X* px = new X; Then he wants to convert px to a char* (I'm guessing for the purpose of...
5
by: brekehan | last post by:
I've always been a little sketchy on the differences between static, dynamic, and reinterpret casting. I am looking to clean up the following block by using C++ casting instead of the C style...
11
by: jois.de.vivre | last post by:
I am interfacing with a third party API (written in C, if that matters) that has an "event handler" function with the following definition: void event_handler(int event_code, unsigned long...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.