comp.lang.ada
 help / color / mirror / Atom feed
* Re: GNAT and a very foreign DLL
@ 2002-01-06  0:31 Alexandre E. Kopilovitch
  2002-01-07 16:19 ` Ted Dennison
  0 siblings, 1 reply; 7+ messages in thread
From: Alexandre E. Kopilovitch @ 2002-01-06  0:31 UTC (permalink / raw)
  To: comp.lang.ada

Ted Dennison<dennison@telepath.com> wrote:
>>  The problem appears to be with the combination of the call convention and
>>the names of the DLL's entry points: the call convention is surely Stdcall,
>>but the entry point names do not contain usual suffixes "@nn" - they look as
>>common C identifiers.
>..
>>  As the Stdcall convention is unavoidable anyway, I was forced to create some
>>"post-linker", which post-processes my executable, replacing "@" in the DLL's
>>entry point names by zero bytes. After that post-processing all works fine,
>
>If the problem is just the name, why don't you just use the "Link_Name"
>parameter to "pragm Import" to specify the name they actually used?

Because with that Link_Name the suffix "@nn" is still appended. As the GNAT
User's Guide honestly says (at the end of Microsoft Windows Topics/Windows
Calling Conventions/Stdcall Calling Convention section):
"... there is no trailing underscore but the appropriate @nn is always added
at the end of the Link_Name by the compiler. "

>However, you may want to check the C header files for that routine to make sure
>the calling convention is what you think it is. I have seen DLL's with routines
>with different conventions in them before.
I checked that, and there are the Stdcall directives indeed. And moreover, all
that stuff works properly with the Stdcall calls.


Alexander Kopilovitch                      aek@vib.usr.pu.ru
Saint-Petersburg
Russia




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: GNAT and a very foreign DLL
  2002-01-06  0:31 GNAT and a very foreign DLL Alexandre E. Kopilovitch
@ 2002-01-07 16:19 ` Ted Dennison
  2002-01-08 15:48   ` GNAT and NT DLL; An Ada-Comment resignation Vim Pine 44
  0 siblings, 1 reply; 7+ messages in thread
From: Ted Dennison @ 2002-01-07 16:19 UTC (permalink / raw)


In article <mailman.1010276762.30835.comp.lang.ada@ada.eu.org>, Alexandre E.
Kopilovitch says...
>Because with that Link_Name the suffix "@nn" is still appended. As the GNAT
>User's Guide honestly says (at the end of Microsoft Windows Topics/Windows
>Calling Conventions/Stdcall Calling Convention section):
>"... there is no trailing underscore but the appropriate @nn is always added
>at the end of the Link_Name by the compiler. "

Yuck. I can see where they'd want to make it work this way, so that things are
easier on the average Windoze developer. But it really hoses you now when you
need that parameter to do exactly what it was put in the spec for.

OTOH, If you feed "External_Name" the exact same name and convention that the C
header file uses, then you ought to be receiving the same thing that the C
header file receives. I don't understand why that isn't working for you,
assuming you are linking in the same library files.

---
T.E.D.    homepage   - http://www.telepath.com/dennison/Ted/TED.html

No trees were killed in the sending of this message. 
However a large number of electrons were terribly inconvenienced.



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: GNAT and NT DLL; An Ada-Comment resignation
  2002-01-07 16:19 ` Ted Dennison
@ 2002-01-08 15:48   ` Vim Pine 44
  2002-01-09 10:20     ` Pascal Obry
  2002-01-10  2:10     ` Robert Dewar
  0 siblings, 2 replies; 7+ messages in thread
From: Vim Pine 44 @ 2002-01-08 15:48 UTC (permalink / raw)






On Mon, 07 Jan 2002 16:19:41 GMT, Ted Dennison wrote:



Below I quote some of the latest messages sent to the Ada-Comment
mailing list, of R. R. Software's Mr Brukardt. This covers the events
leading up to the about-to-occur unsubscribing of Mr R. Dewar.

Firstly about the -k option of gnatdll / dlltool and how to edit the
*.def definition files allowing use of Windows NT Service Pack DLLs.

>In article <mailman.1010276762.30835.comp.lang.ada@ada.eu.org>, Alexandre
>E. Kopilovitch says...
>
>>Because with that Link_Name the suffix "@nn" is still appended. As the
>>GNAT User's Guide honestly says (at the end of Microsoft Windows
>>Topics/Windows Calling Conventions/Stdcall Calling Convention section):
>>"... there is no trailing underscore but the appropriate @nn is always
>>added at the end of the Link_Name by the compiler. "
>
>... [...]If you feed "External_Name" the exact same name and convention
>that the C header file uses, then you ought to be receiving the same
>thing that the C header file receives. I don't understand why that isn't
>working for you, assuming you are linking in the same library files.


----------
On Sat,  5 Jan 2002 01:04:04 +0300 (MSK), "Alexandre E. Kopilovitch"
 wrote:
>[...] GNAT 3.13p on Windows, and some apparently exotic foreign DLL,
>which was written in C or C++ and now should be called from an Ada
>program. The problem appears to be with the combination of the call
>convention and the names of the DLL's entry points: the call convention
>is surely Stdcall, but the entry point names do not contain usual
>suffixes "@nn" - they look as common C identifiers.
---------


[1] Linking in Microsoft Service Pack DLLs into a GNAT program

The "External_Name" and "Link_Name" options are documented here, in
the AARM Annotated Reference Manual:

   http://www.ada-auth.org/arm-html/AA-B-1.html

I suppose the first author of the thread was right in saying that both
of those options do not resolve the problem.

A GNAT for Windows NT program links into a DLL after it gets the *.a
file that was created from the DLL.

By using the dlltool.exe's '--kill-at' option of the equivalent '-k'
option of maybe-ACT's gnatdll.exe, the problem can be fixed.

The linker says "@nn" suffixes should be added, and the way to achieve
that is to use the gnatdll '-k' option to add the suffixes the linker
requires. Maybe that is not right since the gnatdll says the '-k'
feature does this:  "-k   Remove @nn suffix from exported names".

An example showing use of '-k'

   $ dll2def API.dll > API.def
   $ gnatdll -k -e API.def -d API.dll

If a DLL contains a mix of Cdecl and Stdcall subroutines, or bcc32
is used, etc., then the *.def file can be edited.

A sample *.def file that is used by gnatdll/dlltool:

LIBRARY newdll.dll
EXPORTS
   _bccsub
   bccsub=_bccsub
   ntsub
   ntsub@0=ntsub

If the linker says that ntsub@00 is needed, and a use of dumbin.exe
(of Visual C, or of the Aonix compiler) says that the entry in the
DLL is "ntsub" then a line "ntsub@0=ntsub" could be added to the
*.def file. The @nn can be copied from the error messages of the
linker. Once the *.def file is edited correctly then there is no

The *.1 documentation of dlltool does not explain much on *.def
files and how to edit them.

The "LIBRARY" line can help Windows NT get the name of the DLL right.

A way to check for the smashing up of memory that can result from
wrongly using Cdecl to call a Stdcall DLL, is to add a 500 byte
array to the variables of the subroutine having a line making the
improperly mixed call. 

A place that looks like it might document tips and methods for
getting Ada code running smoothly with other compilers, could be:
http://www.adapower.com/
There is a shortage of how to pages there.

------------------------

[2] On the topic: "Is it best to use GCC?."

The MinGW website seems to say no. Some text copied from a
webpage of the mingw.org website's FAQ page:

http://www.mingw.org/mingwfaq.shtml

>There is command-line option that can be passed to Cygwin's
>GCC, "-mno-cygwin", that was intended to address these
>concerns [about copyright and the need to pay Red Hat or else
>release code]. When Cygwin's GCC is invoked with the "-mno-
>cygwin" option, executables are built without a dependency on
>the Cygwin DLL. Instead, the "-mno-cygwin" option instructs
>GCC to use the MinGW headers and libraries (which must be
>located in a particular location within the Cygwin directory
>structure). However, support for "-mno-cygwin" has been weak
>and flaky... the location at which it searches for MinGW
>headers has changed a time or two (with poor documentation),
>bugs have crept in, and maintainence of the option has NOT be
>a priority in development. There is a distinct possibility
>that "-mno-cygwin" will become depreciated in future releases
>of Cygwin.

MinGW executables are smaller than gcc executables. If gcc code
runs than it is not flakey. All of gcc/mingw/bcc32 are no good
at compiling kernel mode drivers.

ACT has reservations about Cygwin Gcc too. This is from a message
that I got from ACT after sending in a request about the free Ada
code that people could not compile.

-------------------------------------
At 2001.12.26 11:28 -0500 Wednesday, dewar@gnat.com wrote:
><<I request that ACT put online information that says how to compile
> the gcc.gnu.org gcc/gcc/ada code in windows NT.
>I.e. for people with GNAT 3.13p installed and maybe Cygwin Gcc.
>>>
>
>We advise against any use of Cygwin GCC, and do not support the use
>of GNAT with Cygwin. That being said, you may be able to successfully
>build a version, and if so, that's just fine with us, but it's not
>something we have done or intend to do.
>
>As for more information, we have no plans at the current time,
>several people have built gcc successfully on NT, but indeed it is
>tricky [could be wrong], requiring [...] hopefully people [...]
-------------------------------------

GNAT Pro users ought be able to get the compiler compiled. Are they
barred a little bit by an agreement with ACT?.

Maybe ACT's Mr Dewar was hinting that MinGW is better than GCC for
Windows NT GNAT user app programs. Anybody got data on that topic?.

Successes at compiling the public GNAT ought appear here
sometime: http://gcc.gnu.org/ml/gcc/

Getting the files:
WinCVS: http://www.devguy.com/fp/cfgmgmt/tools/install.htm
  (Cygwin CVS produces defective Entries files).

$ cvs -d:pserver:anoncvs@gcc.gnu.org:/cvs/gcc login
     (password is ``anoncvs'')
$ cvs -z7 -d:pserver:anoncvs@gcc.gnu.org:/cvs/gcc co -c
     List all the modules and see what groups of files are available.
$ cvs -z7 -d:pserver:anoncvs@gcc.gnu.org:/cvs/gcc co gcc-ada



====================================================================

[3] Quality of discussions at the Ada-Comment list and where to draw
the line over excluding the interests of readers that woudld be
conversational

The topic is one seen from time to time: requesting the thread vanish
and go maybe to comp.lang.ada.

It starts out with a personal message going to a public mailing list,
which seems to be a mistake.


-1--------------------------------------------------------------------

Received: (from ploedere@localhost)
	by ibsen.informatik.uni-stuttgart.de (8.9.3+Sun/8.9.1) id
PAA01857;
	Mon, 7 Jan 2002 15:08:52 +0100 (MET)
Date: Mon, 7 Jan 2002 15:08:52 +0100 (MET)
From: Erhard Ploedereder <ploedere@informatik.uni-stuttgart.de>
To: ada-comment@ada-auth.org
In-reply-to: <000f01c17c54$34e7fb40$0604a8c0@bigboy.rrsoftware.com>
	(Randy@RRSoftware.Com)
List-Server: DOLIST Server Custom 3.4 B2110
List-Help: <mailto:listserv@ada-auth.org?body=help%20ada-comment>
List-Subscribe: <mailto:listserv@ada-auth.org?body=join%20ada-comment>
List-Info: Ada-Comment list
Subject: Re: [Ada-Comment] OT: Request for articles for the AdaIC
site.

Randy,

on a somewhat related topic....a few students of mine have been
searching the net for Ada Software that uses tagged types, i.e. 
the OO-features of Ada and haven't been very successful. 

Any pointers that you might have ?

Erhard

-2--------------------------------------

From: dewar@...
To: ada-comment@ada-aut...
Date: Mon,  7 Jan 2002 11:16:49 -0500 (EST)
Subject: Re: [Ada-Comment] User-defined conversions (or constructors)?

Pascal, I am afraid you do not qualify as an Ada user :-)

[...]

In fact I think Ada comment should NOT be used for general discussions
on ideas, but rather for submissions of ideas, and the discussions
should take place elsewhere, either on CLA for general chat, or on 
the ARG list for serious language work.

There is a danger of comment becoming an Ada chit chat list, in which
case we will need to constitute another separate formal list for
language suggestions and comments on the standard.

-3--------------------------------------

Date: Mon,  7 Jan 2002 17:25:17 -0500 (EST)
To: ada-comment@ada-auth.org
Subject: Re: [Ada-Comment] OT: Request for articles for the AdaIC
 site.

Surely discussion of availability of student materials on Ada does
not belong on the official mailing list for comments on the ISO
standard!.

-4--------------------------------------

From: "Randy Brukardt" <Randy@RR...
To: "'Ada-Comment List'" <ada-comment@ada-aut...
Date: Mon, 7 Jan 2002 16:50:58 -0600

** Brukardt:
  Oops, sorry, I just pushed reply
[...]
I don't agree. The original intent of the ARG list was for
 administrative issues (i.e. meeting announcements and agendas --
 technical discussion was supposed to occur on Ada Comment. And I
 think technical discussion ought to be recorded for posterity -- else
 we're liable to have the same discussions over and over.

So, as a practical matter, the amount of administrative work is the
 same whether the discussion occurs on ARG or on Ada Comment, the only
 difference being that we are more likely to ignore (rather than
 record) discussions on ARG that have obvious answers. There aren't
 many such discussions.

I'm really against using CLA for anything important.
[imperfect Usenet access (bad ISPs). CC.]

So, I'd rather see the technical discussion on Ada-Comment. Which also
 has the advantage of being available to the general public, while ARG
 is closed.
Of course, off-topic stuff and chit-chat should be minimized. I block
 a lot of those messages here before they even go to the list [...]

		Randy Brukardt
		ARG Editor

-5--------------------------------------

From: dewar@gnat.com
Date: Mon,  7 Jan 2002 18:18:38 -0500 (EST)
List-Subscribe: <mailto:listserv@ada-auth.org?body=join%20ada-comment>
Subject: Re: [Ada-Comment] OT: Request for articles for the AdaIC
site.

OK, given Randy's feeling, I am unsubscribing, so silence from me on
this issue simply means I am not seeing any more traffic :-)
I definitely do not want to be on yet another random Ada chat mailing
list

----------------------------------------------------------------------
[end]


A re-shooting could produce a different ending.

List members did not add to the thread except for one that cited
projects that had used the tagged type.

The list: Ada-Comment: http://www.adaic.org/standards/ada95.html

My list of other Ada Lists: http://www.ijs.co.nz/ada_95.htm
Cetus-Links' page: http://www.cetus-links.org/oo_ada.html

Educators can write to the Ada First mailing list. Team-Ada readers
not get less messages saying 'my university prefers Java ... or C'.

  http://osgood.seas.gwu.edu/cgi-bin/lyris.pl  ('Special Topics')




Craig Carey







^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: GNAT and NT DLL; An Ada-Comment resignation
  2002-01-08 15:48   ` GNAT and NT DLL; An Ada-Comment resignation Vim Pine 44
@ 2002-01-09 10:20     ` Pascal Obry
  2002-01-09 17:59       ` Craig Carey
  2002-01-10  2:10     ` Robert Dewar
  1 sibling, 1 reply; 7+ messages in thread
From: Pascal Obry @ 2002-01-09 10:20 UTC (permalink / raw)



Vim Pine 44 <research@ada95.ijs.co.nz> writes:

> MinGW executables are smaller than gcc executables. If gcc code

There is a problem in this sentence. GCC uses MingW, so I don't understand
what you mean ?

There is 2 flavors of GCC on based on Cygwin and one on MingW.

Pascal.

-- 

--|------------------------------------------------------
--| Pascal Obry                           Team-Ada Member
--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE
--|------------------------------------------------------
--|         http://perso.wanadoo.fr/pascal.obry
--|
--| "The best way to travel is by means of imagination"



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: GNAT and NT DLL; An Ada-Comment resignation
  2002-01-09 10:20     ` Pascal Obry
@ 2002-01-09 17:59       ` Craig Carey
  0 siblings, 0 replies; 7+ messages in thread
From: Craig Carey @ 2002-01-09 17:59 UTC (permalink / raw)


On 09 Jan 2002 11:20:05 +0100, Pascal Obry <p.obry@wanadoo.fr> wrote:

>
>** <research@ada95.ijs.co.nz> writes:
>
>> MinGW executables are smaller than gcc executables. If gcc code
>
>There is a problem in this sentence. GCC uses MingW, so I don't understand
>what you mean ?
>
>There is 2 flavors of GCC on[e] based on Cygwin and one on MingW.
>
>Pascal.



I correct my statement, to say that Cygwin executables (not Gcc
executables) are larger. But that is just of the small number I
compared (not enough). 

A Gcc file named configure.in (from cvs files), mentions both of
those two, so maybe the Cygwin code (with a -mno-cygwin) is not
"flaky" (which a Mingw Faq suggested).

--



Craig Carey
http://www.ijs.co.nz/ada_95.htm



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: GNAT and NT DLL; An Ada-Comment resignation
  2002-01-08 15:48   ` GNAT and NT DLL; An Ada-Comment resignation Vim Pine 44
  2002-01-09 10:20     ` Pascal Obry
@ 2002-01-10  2:10     ` Robert Dewar
  2002-01-12 18:01       ` Craig Carey
  1 sibling, 1 reply; 7+ messages in thread
From: Robert Dewar @ 2002-01-10  2:10 UTC (permalink / raw)


Vim Pine 44 <research@ada95.ijs.co.nz> wrote in message news:<vu4m3u8dtigdb5d0vusq4qkur72uibicnd@4ax.com>...
> On Mon, 07 Jan 2002 16:19:41 GMT, Ted Dennison wrote:
> 
> 
> 
> Below I quote some of the latest messages sent to the Ada-Comment
> mailing list, of R. R. Software's Mr Brukardt. This covers the events
> leading up to the about-to-occur unsubscribing of Mr R.
> Dewar.


Just for the record, the subject of this thread is either
confused or deliberately misleading. My decision to unsubscribe has
nothing whatsoever to do with the discussion of GNAT and DLL stuff. By
the way resign is a ludicrous term, this is simply a mailing list to
which people may voluntarily subscribe and unsubscribe. For
me a mailing list has to be close to 100% useful info
to be worth subscribing (CLA is different, it is full
of junk, but I can ignore most threads completely and
never read them :-)



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: GNAT and NT DLL; An Ada-Comment resignation
  2002-01-10  2:10     ` Robert Dewar
@ 2002-01-12 18:01       ` Craig Carey
  0 siblings, 0 replies; 7+ messages in thread
From: Craig Carey @ 2002-01-12 18:01 UTC (permalink / raw)


On 9 Jan 2002 18:10:27 -0800, dewar@gnat.com (Robert Dewar) wrote:

>Vim Pine 44 <research@ada95.ijs.co.nz> wrote in message news:<vu4m3u8dtigdb5d0vusq4qkur72uibicnd@4ax.com>...
>> On Mon, 07 Jan 2002 16:19:41 GMT, Ted Dennison wrote:
>> 
>> 
>> 
>> Below I quote some of the latest messages sent to the Ada-Comment
>> mailing list, of R. R. Software's Mr Brukardt. This covers the events
>> leading up to the about-to-occur unsubscribing of Mr R.
>> Dewar.
>
>
>Just for the record, the subject of this thread is either
>confused or deliberately misleading. My decision to unsubscribe has
>nothing whatsoever to do with the discussion of GNAT and DLL stuff. By
>the way resign is a ludicrous term, this is simply a mailing list to
                                     ^
                                     that Ada-Comment list

>which people may voluntarily subscribe and unsubscribe. For
...


Thanks for correcting me on that. 

I would not have used the word resign if I had of paused longer over
the wording of the Subject field.

While the Subject is inaccurate it fails to say who it is about. So it
might not be misleading at all. In the body of the message, though I
named you, the mistake of using that word was fixed.

You suggested that the public could worsen the public Ada compiler by
putting in Eiffel pre and post conditions. A problem with it is that
the language is trying to get the programmer to use 2 tests per
procedure when the knowledge at hand may allow only 0, 1, or 3 tests.
So that Eiffelism would not be a part of Ada or Aonix Ada, but it
might be part of GNAT. This Ada takes a long time to learn before
people can get experienced with the reasoning. E.g. the number 2 is
not especially important.

I would like to have a look at our GNAT compiler (Richard's while I
am referring to that other thread), and see if I can get a - \ | / -
feature in. Just something like this:

package Lucid is
   procedure R (A : Integer; B : in out Integer; C : out Integer);
   ...
begin
   R (/A, |B, \C);  --  syntax checked and it shows which passes in
                    --  and out. They are optional unless a
                    --  directive says otherwise.

   /Q(12) := \F;    --  Not allowed since strange and not informative

end Lucid;

An advantage of that is the clarity each time the procedure is
called. 


---



Craig Carey






^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2002-01-12 18:01 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-01-06  0:31 GNAT and a very foreign DLL Alexandre E. Kopilovitch
2002-01-07 16:19 ` Ted Dennison
2002-01-08 15:48   ` GNAT and NT DLL; An Ada-Comment resignation Vim Pine 44
2002-01-09 10:20     ` Pascal Obry
2002-01-09 17:59       ` Craig Carey
2002-01-10  2:10     ` Robert Dewar
2002-01-12 18:01       ` Craig Carey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox