Jump to page: 1 2
Thread overview
using C with D
Jul 22, 2007
Micah Heyer
Jul 22, 2007
Gregor Richards
Jul 22, 2007
Saaa
Jul 22, 2007
Gregor Richards
Jul 22, 2007
Saaa
Jul 23, 2007
Gregor Richards
Jul 24, 2007
BCS
Jul 24, 2007
Frits van Bommel
[OT] Re: using C with D -- Re: Dutch
Jul 24, 2007
BCS
Jul 25, 2007
Gregor Richards
Jul 25, 2007
Derek Parnell
Jul 22, 2007
Sean Kelly
Jul 22, 2007
Anders Bergh
Jul 23, 2007
Micah Heyer
Jul 23, 2007
Gregor Richards
July 22, 2007
Hi everyone,
 Lately I've been taking another look at D and I've been thinking about using it instead of c++,but the single most thing holding me back is the ability to use C libraries with out having to recreate the headers.I understand why this feature was left out of D,but with out the ability to easily use C libraries I just have to stick with C++.To me one of the  strengths of C++ and probably one of the reasons it is in use as much as it is to day is that it is backwards compatible with C.
So here is what I'm wondering: would it be possible, through modification of gcc,to have the compiler export a D style symbol table for importing into D projects?Is this a ridiculous idea or would it actully be feasible?

-micah
July 22, 2007
Micah Heyer wrote:
> Hi everyone,
>  Lately I've been taking another look at D and I've been thinking about using it instead of c++,but the single most thing holding me back is the ability to use C libraries with out having to recreate the headers.I understand why this feature was left out of D,but with out the ability to easily use C libraries I just have to stick with C++.To me one of the  strengths of C++ and probably one of the reasons it is in use as much as it is to day is that it is backwards compatible with C.
> So here is what I'm wondering: would it be possible, through modification of gcc,to have the compiler export a D style symbol table for importing into D projects?Is this a ridiculous idea or would it actully be feasible?
> 
> -micah

Not only is it feasible, I did it months ago.

http://www.dsource.org/projects/bcd/

 - Gregor Richards
July 22, 2007
What exactly is the difference between bcd and htod?
I've read both of the websites and am I right to say they both rewrite the
header file to a D compatible module?

>
> Not only is it feasible, I did it months ago.
>
> http://www.dsource.org/projects/bcd/
>
>  - Gregor Richards


July 22, 2007
On 7/22/07, Gregor Richards <Richards@codu.org> wrote:
> Not only is it feasible, I did it months ago.
>
> http://www.dsource.org/projects/bcd/

I don't think I've thanked you for bcd... it's a great tool! It works
on nearly anything I feed it.

-- 
Anders
July 22, 2007
Saaa wrote:
> What exactly is the difference between bcd and htod?
> I've read both of the websites and am I right to say they both rewrite the header file to a D compatible module?
> 
>> Not only is it feasible, I did it months ago.
>>
>> http://www.dsource.org/projects/bcd/
>>
>>  - Gregor Richards 
> 
> 

1) bcd.gen is F/OSS
2) bcd.gen is portable
3) bcd.gen supports (limited) C++

 - Gregor Richards
July 22, 2007
Saaa wrote:
> What exactly is the difference between bcd and htod?
> I've read both of the websites and am I right to say they both rewrite the header file to a D compatible module?

I haven't tried bcd yet, but in my experience, htod doesn't actually work that well for headers including macros (which seems to be most C headers I've actually needed to convert).  I found it was often faster to convert headers by hand than it was to run them through htod and then do manual cleanup afterwards.


Sean
July 22, 2007
Ah ok :)

Just a question, nothing concrete, but should I report faulty translations?
(.h(C) to .d)
Or do you know of limitations(such as Sean Kelly reports about htod)

>
> 1) bcd.gen is F/OSS
> 2) bcd.gen is portable
> 3) bcd.gen supports (limited) C++
>
>  - Gregor Richards


July 23, 2007
Saaa wrote:
> Ah ok :)
> 
> Just a question, nothing concrete, but should I report faulty translations? (.h(C) to .d)
> Or do you know of limitations(such as Sean Kelly reports about htod)
> 
>> 1) bcd.gen is F/OSS
>> 2) bcd.gen is portable
>> 3) bcd.gen supports (limited) C++
>>
>>  - Gregor Richards 
> 
> 

Macros are always a problem, but I haven't found them as problematic with bcd.gen as Sean apparently has with htod. I don't know if this is due to different implementation, or just because I haven't tested bcd.gen on the same kinds of things.

Yes, report failures directly to my email. I may or may not fix :P

Confusing very things makes it, newsgroups in post-top don't please, way the by.

 - Gregor Richards
July 23, 2007
Gregor Richards wrote:
> 
> Not only is it feasible, I did it months ago.
> 
> http://www.dsource.org/projects/bcd/
> 
>  - Gregor Richards
Ah, thats a nifty little program,I think info about it should be placed in the faq.One question though: What's all the aliased function pointers I keep getting in the output?
alias int function(void *, void *) _BCD_func__788;
alias int function(void *) _BCD_func__409;
alias int function(void *, long *, int) _BCD_func__411;
alias int function(void *, char *, uint) _BCD_func__413;
alias int function(void *, char *, uint) _BCD_func__415;
alias void function(void *) _BCD_func__895;
alias int function(void * *, char *) _BCD_func__896;
alias int function(char *, char * * *, uint *) _BCD_func__897;
alias int function(void *, char *, char *, char *, char *) _BCD_func__898;
alias int function(__gconv_step *, __gconv_step_data *, void *, char *, char * *, char *, char * *, uint *) _BCD_func__899;
alias void function(__gconv_step *) _BCD_func__900;
alias int function(__gconv_step *) _BCD_func__901;
alias uint function(__gconv_step *, char) _BCD_func__902;
alias int function(__gconv_step *, __gconv_step_data *, char * *, char *, char * *, uint *, int, int) _BCD_func__903;

I was converting sdl headers btw.

-micah
July 23, 2007
Micah Heyer wrote:
> Gregor Richards wrote:
>>
>> Not only is it feasible, I did it months ago.
>>
>> http://www.dsource.org/projects/bcd/
>>
>>  - Gregor Richards
> Ah, thats a nifty little program,I think info about it should be placed in the faq.One question though: What's all the aliased function pointers I keep getting in the output?
> alias int function(void *, void *) _BCD_func__788;
> alias int function(void *) _BCD_func__409;
> alias int function(void *, long *, int) _BCD_func__411;
> alias int function(void *, char *, uint) _BCD_func__413;
> alias int function(void *, char *, uint) _BCD_func__415;
> alias void function(void *) _BCD_func__895;
> alias int function(void * *, char *) _BCD_func__896;
> alias int function(char *, char * * *, uint *) _BCD_func__897;
> alias int function(void *, char *, char *, char *, char *) _BCD_func__898;
> alias int function(__gconv_step *, __gconv_step_data *, void *, char *, char * *, char *, char * *, uint *) _BCD_func__899;
> alias void function(__gconv_step *) _BCD_func__900;
> alias int function(__gconv_step *) _BCD_func__901;
> alias uint function(__gconv_step *, char) _BCD_func__902;
> alias int function(__gconv_step *, __gconv_step_data *, char * *, char *, char * *, uint *, int, int) _BCD_func__903;
> 
> I was converting sdl headers btw.
> 
> -micah

Because of how GCCXML works internally, it's easier to alias the functions to alternative names in one step, and then use those alternative names in another step. It's a bit weird, but it doesn't make life any more difficult so long as you stick to this one rule: Don't use the generated .d files as documentation, use the .h files :)

 - Gregor Richards

PS: The lines with gconv_step is a bug I haven't tracked down. It's easy to fix the generated headers by just removing those lines.
« First   ‹ Prev
1 2