Re: Pointer corruption calling across a DLL boundary
From: Doug Harrison [MVP] (dsh_at_mvps.org)
Date: 03/08/04
- Next message: tomaste: "stream I/O coversion"
- Previous message: Newbie one Kanewbie: "RE: Typecasting System:Object in MC++"
- In reply to: Nick Bishop: "Re: Pointer corruption calling across a DLL boundary"
- Next in thread: Nick Bishop: "Re: Pointer corruption calling across a DLL boundary"
- Reply: Nick Bishop: "Re: Pointer corruption calling across a DLL boundary"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 08 Mar 2004 17:43:31 -0600
Nick Bishop wrote:
>"Feng Yuan [MSFT]" <fyuan@online.microsoft.com> wrote in message news:<eh$6GyYAEHA.752@TK2MSFTNGP09.phx.gbl>...
>> Make sure they are compiled using the same compile option. One thing could
>> be wrong is struct packing.
>>
>> This kind of problem could normally be figured out easily by stepping throug
>> in assembly code.
>
>and we also got this answer.
>
>> There's no difference. Maybe the compiler or linker chokes on
>> exported array variables. Try char** instead of char*[].
Except in function parameter declarations, there's a huge difference between
char** and char*[], which respectively declare a pointer to a pointer and an
array of indeterminate size of pointers. In the array to pointer conversion,
char*[whatever] is converted to char**, so Ritchie thought it cool to allow
the array syntax when declaring function parameters. But in order to do
this:
//In the Big Program, the workaround is to declare a local copy of the
//pointer.
//static const char* const myOneTwo[] =
// {
// "One", "Two", 0
// };
The object myOneTwo must be an array. You can't just replace it with char**.
And the above is not a local copy of a pointer; it's an array, a duplication
of the entire array defined by your DLL.
I agree with Feng Yuan. You need to look at the disassembly of the call
point and determine exactly what is being passed to your function. In
addition, you should be linking every module you expect to share C++ objects
like this with the same CRT DLL.
-- Doug Harrison Microsoft MVP - Visual C++
- Next message: tomaste: "stream I/O coversion"
- Previous message: Newbie one Kanewbie: "RE: Typecasting System:Object in MC++"
- In reply to: Nick Bishop: "Re: Pointer corruption calling across a DLL boundary"
- Next in thread: Nick Bishop: "Re: Pointer corruption calling across a DLL boundary"
- Reply: Nick Bishop: "Re: Pointer corruption calling across a DLL boundary"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|