www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Using C libraries

reply Anders Runesson <arson disoriented.org> writes:
Hello.
I'm quite new to this "d"-thing, but it seems very interesting and i think i
will use it, if i can clear a few things up. I have, based on the reading i
have done, made the following assumptions, please correct me where i'm
wrong. 

1. D can link to C libraries. The standard c library have been wrapped(all
functions redeclared with "extern (C) ...") in std.c.xxx-modules, so we can
use them easily. 

2. I cannot use functions from a c library unless i have declared them as
extern (C) in my D source code. Structures in the c library that i want to
use in my code have to be declared in my D code.
May 30 2004
next sibling parent Stephan Wienczny <wienczny web.de> writes:
Anders Runesson wrote:
 Hello.
 I'm quite new to this "d"-thing, but it seems very interesting and i think i
 will use it, if i can clear a few things up. I have, based on the reading i
 have done, made the following assumptions, please correct me where i'm
 wrong. 
 
 1. D can link to C libraries. The standard c library have been wrapped(all
 functions redeclared with "extern (C) ...") in std.c.xxx-modules, so we can
 use them easily. 
Correct.
 
 2. I cannot use functions from a c library unless i have declared them as
 extern (C) in my D source code. Structures in the c library that i want to
 use in my code have to be declared in my D code.
That's correct, too. How should the compiler know about the functions and structures if you don't do that? Stephan
May 30 2004
prev sibling parent "Walter" <newshound digitalmars.com> writes:
"Anders Runesson" <arson disoriented.org> wrote in message
news:c9d1qt$6es$1 digitaldaemon.com...
 Hello.
 I'm quite new to this "d"-thing, but it seems very interesting and i think
i
 will use it, if i can clear a few things up. I have, based on the reading
i
 have done, made the following assumptions, please correct me where i'm
 wrong.

 1. D can link to C libraries. The standard c library have been wrapped(all
 functions redeclared with "extern (C) ...") in std.c.xxx-modules, so we
can
 use them easily.

 2. I cannot use functions from a c library unless i have declared them as
 extern (C) in my D source code. Structures in the c library that i want to
 use in my code have to be declared in my D code.
Both assumptions are correct.
May 30 2004