Interfacing D with C: Getting Started

Mike Parker aldacron at gmail.com
Wed Dec 6 10:50:12 UTC 2017


On Wednesday, 6 December 2017 at 08:20:25 UTC, Johan Engelen 
wrote:

> Overall I find that it'd be much nicer if you focus on C-D 
> interaction only. Currently you've added a lot of things that 
> people really would already know before reading the text: I 
> think preknowledge should be how to create programs in C and in 
> D (including compilers, etc.). Especially on a second read, 
> it's a lot of scrolling back and forth to find the good nuggets 
> of info.

Thanks for the feedback! I'm taking the bits about structure and 
layout and leaving the bits about content :-)

While combining D and C is the focus of the series, the 
motivation for this specific post is entirely to make sure 
everyone knows how to generate object files using all the 
different C compilers. I really want them to compile things 
themselves as they go along. The bit about c_ulong at the end was 
something I threw in as an example of what's to come.

While I would love to assume that everyone reading will already 
know how to work with the C command line tools, experience has 
shown me that is a misplaced assumption. We've got a lot of 
people coming to D who have never touched C or the command line, 
or if they have it's been in an IDE and their command line 
experience is limited. So my intent is to keep the command line 
minimal and take nothing for granted.

FYI, this started as one post that I wrote a few weeks back about 
C and D strings. But a series of comments here on the forums 
reminded me of all the issues people keep having with getting D 
set up on Windows (something that still baffles me, but it is 
what it is). Then one idea led to another and here we are, with a 
beginner-level tutorial as the fist post in a series.

The next few posts will focus exclusively on the details (arrays, 
strings, exception handling, calling conventions) and refer those 
who need it back to this post. I also plan to cover calling D 
from C, and segue in to a couple about betterC and how the 
absence of the runtime affects things.



More information about the Digitalmars-d-announce mailing list