Covert a complex C header to D

Ali Çehreli via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Apr 4 07:45:26 PDT 2017


On 04/02/2017 02:43 PM, biocyberman wrote:
 > khash.h
 > 
(http://attractivechaos.github.io/klib/#Khash%3A%20generic%20hash%20table)
 > is a part of klib library in C. I want to covert it to D in the process
 > of learning deeper about D.

These are macros used by the library developer to generate library 
facilities without repetition. Not uncommon for C libraries... As 
Nicholas Wilson says, just ignore most of these macros because in the 
end what you want are the types and functions that the public interface 
of the library includes. (Or, the public documentation of the library 
includes.)

In this case, looking at the preprocessor output to see what is 
generated may help. For example, use the -E compiler switch of gcc. If 
you're not familiar with this switch, you may be intimidated at first as 
it includes all headers that your header includes itself. Just search 
for the said library types and functions to see how they ended up like 
after preprocessing.

Ali



More information about the Digitalmars-d-learn mailing list