Using D libs in C

Jesse Phillips jessekphillips+D at gmail.com
Sun Mar 27 08:15:47 PDT 2011


Dainius (GreatEmerald) Wrote:

> Well, the situation is like this: D creates a list of names of files
> that should be loaded by C. C then takes the list, uses it to load the
> files, then stores both the pointers to the loaded files and the names
> of the files in an array of structs. Then when C wants to access the
> files, it asks D about which file to access, which then sends the file
> name, and C compares the known file names and on finding a match,
> accesses the file.
> So that means that the array should be pretty much read-only there,
> but C needs to know how big the newly created array of structs has to
> be. As for how long the list of file names will be - it's determined
> by the configuration, so it will be anywhere from 1 to around 300 or
> even more.

If you want to pass an array of file names to C, you must pass it as a char**, accomplished as bearophile has stated.

Since your C program is asking D which files to work with next why doesn't it load the file at that time? If the file is processed multiple times, you can still cache the data and just check if it is already cached.


More information about the Digitalmars-d-learn mailing list