For Programmers: Free Programming Magazines  


Home > Archive > Compilers > May 2005 > Re: Help a newbie understand how to create a "native library" for any new l









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: Help a newbie understand how to create a "native library" for any new l
Skandinavisches Seminar

2005-05-15, 3:57 am

"rdc02271" <rdc02271@yahoo.com> schrieb im Newsbeitrag
>
> Can any of you show me an example of what would be the perfect
> solution for the libraries problems?


Sorry, there's usually no such thing as a perfect solution.

I recommend the book _Linkers and Loaders_ by John R. Levine (the
moderator of this newsgroup) and the documentation of GNU Libtool:
http://www.gnu.org/software/libtool/libtool.html. You might want to
take a look at the relevant chapters in Kernighan and Ritchie, _The C
Programming Language_ and Stroustrup, _The C++ Programming Language_.
This will give you a clearer idea of what libraries are. You could
also take a look at the source code of the GNU implementations of the
C and C++ standard libraries.

Generally speaking, a library for C will be written in C, a library
for C++ in C++, etc. Assembler is platform-specific, so it's not a
good choice for code that's intended to be ported to other systems.
It's best suited for platform-specific optimizations, not for large
programming tasks.

> When you create a new langauge like D how do you create the
> libraries to work with the operating system (for instance Windows) ?


I can't help you with Windows, but in Unix-like systems, the operating
system provides so-called "system calls" in order to make it possible
for programs to communicate with the operating system.
Implementations of C provide functions that map to these system calls,
so that programmers can access them from their programs. 'creat',
'fork', 'exec', 'read' and 'write' are such system calls. The C
standard does not specify what they do, since they may differ from
system to system.

Laurence Finston
Hans Aberg

2005-05-15, 8:58 pm

"Skandinavisches Seminar" <skandgoe@gwdg.de> wrote:

> Generally speaking, a library for C will be written in C, a library
> for C++ in C++, etc.


Even though this is true on the source code level, it seems that on
the object code level, one way to do it is to mangle the code into a
C-library. For example, when doing this, the C++ directive 'extern "C"
.....' becomes a directive 'do not C++ mangle ..., but use C
conventions directly'.

--
Hans Aberg
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com