comp.lang.ada
 help / color / mirror / Atom feed
* List of C function usable in Ada
@ 2002-10-15  9:43 Sim Con
  2002-10-15 10:58 ` Dale Stanbrough
  2002-10-15 17:20 ` Mark Johnson
  0 siblings, 2 replies; 11+ messages in thread
From: Sim Con @ 2002-10-15  9:43 UTC (permalink / raw)


Hello! where can i find a list of C functions (with parameters and what
they do)usable in Ada? Thanx in advance ^_^


-- 
Posted via Mailgate.ORG Server - http://www.Mailgate.ORG



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

* Re: List of C function usable in Ada
@ 2002-10-15  9:47 Grein, Christoph
  2002-10-15 10:29 ` Sim Con
  0 siblings, 1 reply; 11+ messages in thread
From: Grein, Christoph @ 2002-10-15  9:47 UTC (permalink / raw)


> Hello! where can i find a list of C functions (with parameters and what
> they do)usable in Ada? Thanx in advance ^_^


Nowhere, I presume - or do you think each and every C program that has been 
written in this world exports its functions to a central documentation place.

Seriously, which C functions do you mean?



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

* Re: List of C function usable in Ada
  2002-10-15  9:47 Grein, Christoph
@ 2002-10-15 10:29 ` Sim Con
  2002-10-15 10:34   ` Preben Randhol
  2002-10-17  5:45   ` Gisle Sælensminde
  0 siblings, 2 replies; 11+ messages in thread
From: Sim Con @ 2002-10-15 10:29 UTC (permalink / raw)


> Nowhere, I presume - or do you think each and every C program that has been 
> written in this world exports its functions to a central documentation place.
> 
> Seriously, which C functions do you mean?

Well, i study pragma import just today ;P and i don't understand well
how and where my compiler (adagide and gnat) takes the C function that i
use (for example strlen, rename etc.).
Can you explain me how can i insert other c functions and where the
compiler has the standard one? Thanx again, sorry for my strange
questions ;P




-- 
Posted via Mailgate.ORG Server - http://www.Mailgate.ORG



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

* Re: List of C function usable in Ada
  2002-10-15 10:29 ` Sim Con
@ 2002-10-15 10:34   ` Preben Randhol
  2002-10-15 12:20     ` Sim Con
  2002-10-17  5:45   ` Gisle Sælensminde
  1 sibling, 1 reply; 11+ messages in thread
From: Preben Randhol @ 2002-10-15 10:34 UTC (permalink / raw)


Sim Con wrote:
>> Nowhere, I presume - or do you think each and every C program that has been 
>> written in this world exports its functions to a central documentation place.
>> 
>> Seriously, which C functions do you mean?
> 
> Well, i study pragma import just today ;P and i don't understand well
> how and where my compiler (adagide and gnat) takes the C function that i
> use (for example strlen, rename etc.).

what is strlen and rename? I mean what do they do?

-- 
Ada95 is good for you.
http://libre.act-europe.fr/Software_Matters/02-C_pitfalls.pdf



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

* Re: List of C function usable in Ada
  2002-10-15  9:43 List of C function usable in Ada Sim Con
@ 2002-10-15 10:58 ` Dale Stanbrough
  2002-10-15 17:20 ` Mark Johnson
  1 sibling, 0 replies; 11+ messages in thread
From: Dale Stanbrough @ 2002-10-15 10:58 UTC (permalink / raw)


Sim Con <sicon@hotmail.com> wrote:

> Hello! where can i find a list of C functions (with parameters and what
> they do)usable in Ada? Thanx in advance ^_^

? you can call almost any C function from standard Ada. The only
real problem are those that contain varargs.

Dale



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

* Re: List of C function usable in Ada
@ 2002-10-15 11:03 Grein, Christoph
  0 siblings, 0 replies; 11+ messages in thread
From: Grein, Christoph @ 2002-10-15 11:03 UTC (permalink / raw)


> Well, i study pragma import just today ;P and i don't understand well
> how and where my compiler (adagide and gnat) takes the C function that i
> use (for example strlen, rename etc.).
> Can you explain me how can i insert other c functions and where the
> compiler has the standard one? Thanx again, sorry for my strange
> questions ;P

There is an example that comes with Gnat showing how to link and Ada program with C 
subprograms.



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

* Re: List of C function usable in Ada
  2002-10-15 10:34   ` Preben Randhol
@ 2002-10-15 12:20     ` Sim Con
  2002-10-15 13:09       ` Preben Randhol
  0 siblings, 1 reply; 11+ messages in thread
From: Sim Con @ 2002-10-15 12:20 UTC (permalink / raw)


> what is strlen and rename? I mean what do they do?

strlen returns the lenght of a string and rename rename a file , 2
useful c functions (especially the rename one, since it isn't built in
ada) ;)




-- 
Posted via Mailgate.ORG Server - http://www.Mailgate.ORG



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

* Re: List of C function usable in Ada
@ 2002-10-15 12:53 Grein, Christoph
  0 siblings, 0 replies; 11+ messages in thread
From: Grein, Christoph @ 2002-10-15 12:53 UTC (permalink / raw)


> strlen returns the lenght of a string and rename rename a file , 2
> useful c functions (especially the rename one, since it isn't built in
> ada) ;)

Of course strlen exists in Ada, only its name is different. See attributes.

With Gnat, there is an OS library that you can use for renaming and other 
functionality.



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

* Re: List of C function usable in Ada
  2002-10-15 12:20     ` Sim Con
@ 2002-10-15 13:09       ` Preben Randhol
  0 siblings, 0 replies; 11+ messages in thread
From: Preben Randhol @ 2002-10-15 13:09 UTC (permalink / raw)


Sim Con wrote:
>> what is strlen and rename? I mean what do they do?
> 
> strlen returns the lenght of a string and rename rename a file , 2
> useful c functions (especially the rename one, since it isn't built in
> ada) ;)

And strlen is useful how in Ada? Why don't you use Ada to find the
length of a string ?

As for rename if you use GNAT you find it in GNAT.OS_Lib (filename :
g-os_lib.ads and g-os_lib.adb)

   procedure Rename_File
        (Old_Name : String;
         New_Name : String;
         Success  : out Boolean);

   --  Rename a file. Successis set True or False indicating if the
   --  rename is successful.

If you want to learn how to import "C" you can look at the
implementation of Rename_File.

-- 
Ada95 is good for you.
http://libre.act-europe.fr/Software_Matters/02-C_pitfalls.pdf



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

* Re: List of C function usable in Ada
  2002-10-15  9:43 List of C function usable in Ada Sim Con
  2002-10-15 10:58 ` Dale Stanbrough
@ 2002-10-15 17:20 ` Mark Johnson
  1 sibling, 0 replies; 11+ messages in thread
From: Mark Johnson @ 2002-10-15 17:20 UTC (permalink / raw)


Sim Con wrote:
> 
> Hello! where can i find a list of C functions (with parameters and what
> they do)usable in Ada? Thanx in advance ^_^
> 
Hmm. I don't quite think you received a direct answer to your query.
Just about any C function can be called from Ada with a suitable
compiler. To get a list of C functions (on Unix or Linux), I suggest
running xman, select Manual Page, and then select sections 2 or 3 to get
a list of system calls and functions. Depending on your set up, a few
other sections may also have callable functions - YMMV.

Of course, the next question is "how" to call them and the necessary
interfaces that are needed. As commented in other replies, you *could*
call strlen to determine the length of a null terminated string.
However, a string in Ada may or may not be terminated by nulls. You
would have to do the conversion between Ada and C strings before calling
strlen. You should use the features documented in Annex B (interface
pragmas, the package Interfaces) as well.

Having said all that, you might be better off using the capabilities
that Ada already provides before calling any C functions.

Good luck.
  --Mark



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

* Re: List of C function usable in Ada
  2002-10-15 10:29 ` Sim Con
  2002-10-15 10:34   ` Preben Randhol
@ 2002-10-17  5:45   ` Gisle Sælensminde
  1 sibling, 0 replies; 11+ messages in thread
From: Gisle Sælensminde @ 2002-10-17  5:45 UTC (permalink / raw)


Sim Con wrote:
>> Nowhere, I presume - or do you think each and every C program that has been 
>> written in this world exports its functions to a central documentation place.
>> 
>> Seriously, which C functions do you mean?
> 
> Well, i study pragma import just today ;P and i don't understand well
> how and where my compiler (adagide and gnat) takes the C function that i
> use (for example strlen, rename etc.).
> Can you explain me how can i insert other c functions and where the
> compiler has the standard one? Thanx again, sorry for my strange
> questions ;P

I think strlen and rename are part of libc, the standard C library.
On unix and unix-like systems the libc is usually linked to every
executable. GCC (which GNAT is based) was originally implemented 
for unix-like systems, and the ports to non-unix systems contains a
compatibility layer, since the gcc runtime need it. For GNAT
on Windows the mingw library are used. There is also cygwin, that 
unlike mingw tries to be a complete compatibility layer, and not just
the minimum needed to support gnu tools.                        
                                                         
For this reason, strlen etc will always be there. For more interesting
C functions, you must link with the library where they are located when   
building the Ada executable.

--
Gisle S�lensminde ( gisle@ii.uib.no )   

With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going
to land, and it could be dangerous sitting under them as they fly
overhead. (from RFC 1925)



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

end of thread, other threads:[~2002-10-17  5:45 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-10-15  9:43 List of C function usable in Ada Sim Con
2002-10-15 10:58 ` Dale Stanbrough
2002-10-15 17:20 ` Mark Johnson
  -- strict thread matches above, loose matches on Subject: below --
2002-10-15  9:47 Grein, Christoph
2002-10-15 10:29 ` Sim Con
2002-10-15 10:34   ` Preben Randhol
2002-10-15 12:20     ` Sim Con
2002-10-15 13:09       ` Preben Randhol
2002-10-17  5:45   ` Gisle Sælensminde
2002-10-15 11:03 Grein, Christoph
2002-10-15 12:53 Grein, Christoph

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