delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1997/03/26/22:35:16

From: drs AT inxpress DOT net (DRS)
Subject: API's that certainly do work. [was; Re: Windows API calls that don't work? (Was RE: Stupid stupid question :/)
26 Mar 1997 22:35:16 -0800 :
Approved: cygnus DOT gnu-win32 AT cygnus DOT com
Distribution: cygnus
Message-ID: <333897C6.777A.cygnus.gnu-win32@inxpress.net>
References: <01BC386B DOT 709FACA0 AT gbird0> <33367A5B DOT 7807 AT netcom DOT com>
Reply-To: drs AT inxpress DOT net
Mime-Version: 1.0
X-Mailer: Mozilla 3.01Gold (Win95; I)
Original-To: Jim Balter <jqb AT netcom DOT com>
Original-CC: gnu-win32 AT cygnus DOT com
Original-Sender: owner-gnu-win32 AT cygnus DOT com

Jim Balter wrote:

> Under NT 4.0, the program dies just by virtue of *referencing*
> GetFullPathName, without calling it (as APS said). 

Huh. Must be a bug in the linker. (Not.)

The following code compiles and works correctly under win95. I suggest 
it may work on your system, too.

// g++ -o test.exe test.cpp  

#include <windows.h>
#include <iostream.h>
	
LPTSTR lpFilePart;
                   
main()
{
	DWORD (*api)( LPCTSTR file, DWORD length, 
			LPTSTR buf, LPTSTR *lpFile);  
	api = GetFullPathName;
	char* lpFileName = "test.exe";
	char* buffer = new char[256];
	 (*api)(lpFileName, 256, buffer, &lpFilePart); 
	cout << "buffer: " << buffer << endl;
	cout << "filename: " << lpFilePart << endl;
	delete [] buffer;
	return 0;              
}

So even though you and Phil claim to have found a linker bug, I have
yet to be able to reproduce it. The function works correctly 
either referenced as a pointer, or simply on it's own. I don't know 
why you are trying to reference the function name (it has nothing to
do with calling the api) but you brought it up. I can find no trace 
of the problems you guys describe. All of the API's mentioned work
fine for me. So *maybe* it's an NT thing. 

Maybe not.


> The following is enough to cause the access violation:
> 
>   #include <windows.h>
> 
>   void (*xxx)() = GetFullPathName;
> 

The correct prototype for GetFullPathName looks like this, Jim:

DWORD (*api)( LPCTSTR file, DWORD length, LPTSTR buf, LPTSTR
*lpFilePart);  
        
[...]
> Your arrogance is unwarranted and unearned.

Perhaps. But my code seems to work, while yours and Phil's doesn't. ;)

>There is nothing
> in any SDK that would indicate that MessageBoxes should never show up,
> with not even a Dr. Watson popup.  The fact that the code works as
> advertised on *your* system is irrelevant when the behavior of the code
> on *APS's* system was described ("silent death") and is incorrect.

I hate to disagree. I can only mention many hours of frustration in the
old win16 days, trying to figure out why an app silently failed.

If my code sample fails on your system (or Phils) then I will be happy
to
agree--something is wrong with the linker or perhaps the NT version of
the function. On the other hand, if it works under NT, then I hope
and expect you to acknowledge as much. Everyone makes mistakes 
in their code, but not all of us immediately blame the toolset for 
our problems. 

Regards as always.
--DRS
-
For help on using this list, send a message to
"gnu-win32-request AT cygnus DOT com" with one line of text: "help".

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019