De-Referencing A Pointer
James Dunne
james.jdunne at gmail.com
Tue Mar 21 19:39:03 PST 2006
Rory Starkweather wrote:
> I'm totally lost now. The DLL version didn't like the wchar* types and
> it wouldn't compile. So I tried the command line version. It not only
> compiled, it worked perfectly. (Except for tht nasty and long forgotten
> 0 based things.)
>
> So I copied the command line version over the DLL version and I get:
>
> e:\DigitalMars\DMD\Bin\..\..\dm\bin\link.exe dinstr,,,user32+kernel32/noi;
>
> OPTLINK (R) for Win32 Release 7.50B1
> Copyright (C) Digital Mars 1989 - 2001 All Rights Reserved
>
> OPTLINK : Warning 23: No Stack
> dinstr.obj(dinstr)
> Error 42: Symbol Undefined __nullext
> dinstr.obj(dinstr)
> Error 42: Symbol Undefined __ModuleInfo_3std6string
> OPTLINK : Warning 134: No Start Address
> --- errorlevel 2
>
> I can't see a difference between what is in DInStr.d now and the code
> below that was posted before any changes. The new version is posted
> below the >> version, which is from an earlier message at a time when it
> compiled OK, but didn't work.
>
>>> ******************************* Here's the ** OLD *** D code:
>>>
>>> //--------DInStr.d-----------
>>> import DLLMain;
>>> import std.string; // For find
>>>
>>> extern (Windows)
>>> {
>>> int findACharInString(char* searchString, char* searchChar)
>>> {
>>> int iPointer = 0;
>>> char[] theChar;
>>> char[] theString;
>>>
>>> theString = std.string.toString(searchString);
>>> theChar = std.string.toString(searchChar);
>>>
>>> iPointer = find(theString, theChar);
>>>
>>> return (iPointer);
>>> }
>>> }
>
>
> ******************************* Here's the ** NEW *** D code:
> //--------DInStr.d-----------
> import DLLMain;
> import std.string; // For find
>
> extern (Windows)
> {
> int findACharInString(char* searchString, char* searchChar)
> {
> int iPointer = 0;
> char[] theChar;
> char[] theString;
>
> theString = std.string.toString(searchString);
> theChar = std.string.toString(searchChar);
>
> iPointer = find(theString, theChar);
>
> return (iPointer);
> }
> }
>
> As I said, I can't see the difference.
>
> To confuse the issue even further, here's the commandline version, that
> works perfectly. I realize that I am passing char[] to findACharInString
> in this version but I don't see why it compiles without a hitch.
>
> Command line used: DInstrCL Fred e
>
> //--------DInStrCL.d-----------
> import DLLMain;
> import std.string; // For find
>
> extern (Windows)
> {
> int findACharInString(char* searchString, char* searchChar)
> {
> int iPointer = 0;
> char[] theChar;
> char[] theString;
>
> theString = std.string.toString(searchString);
> theChar = std.string.toString(searchChar);
>
> iPointer = find(theString, theChar);
>
> return (iPointer);
> }
> }
>
> void main(char[][] Args)
> {
> int iRetVal;
>
> iRetVal = findACharInString(Args[1], Args[2]);
>
> printf("%.*s found at %d\n", Args[2], iRetVal);
> }
As much as I'd love to help you out, I'm also hopelessly lost. Can you
ZIP up your project and document your test cases and post them on the NG
or e-mail them to me personally? The e-mail I post with on the
newsgroups is my valid e-mail.
--
Regards,
James Dunne
More information about the Digitalmars-d-learn
mailing list