More automated interfacing of D with C codebases

Brad Lanam brad.lanam.comp at -NOSPAM-gmail.com
Tue Oct 23 10:42:36 PDT 2012


On Tuesday, 23 October 2012 at 06:35:06 UTC, Jacob Carlborg wrote:
> On 2012-10-22 21:48, Brad Lanam wrote:
> How can you mention bourne shell and portability in the same 
> sentence? I doesn't work on Windows (yes I know about cygwin 
> and mingw). Clang does work on Windows, I just haven't been 
> able to compile DStep for Windows yet due to optlink not 
> cooperating.
>
> Sure, if you're satisfied with Posix then I guess that's fine. 
> But it's not really easy to build cross-platform code with 
> shell script.

I'm sorry, I don't see how that follows.  My scripts work on All 
variants of Linux (2.4, 2.6), Solaris (2.6 - 11), AIX, Tru64, 
HP-UX, All *BSD, Mac OSX, Haiku, QNX, SCO, Syllable, UnixWare, 
Windows Cygwin.  My 'di' program builds on all of the above with 
a simple 'make' as it uses my build tool.  And I don't need to 
install any special tools.  These are just the systems I have 
access to.

How is that not cross-platform?  How is that not portable?  How 
is that not easy?

If I had a D compiler on all those platforms, the D version of 
the 'di' program would build everywhere with just a 'make'.

>> If you need to write code that runs on multiple systems and 
>> works with
>> low level system calls (rpc, et.al.), my tool might be a 
>> better choice.
>
> Why would that make a difference.

Not all systems are alike.

       static if (_c_args_setmntent == 1)
       {
         f = setmntent (toStringz(DI_MOUNT_FILE));
       } else static if (_c_args_setmntent == 2) {
         f = setmntent (toStringz(DI_MOUNT_FILE), toStringz("r"));
       }

If I understand your tool correctly, you might convert the 
mount.h or mntent.h file [but how does your program decide which 
one and even if they exist?].  But then how are you going to 
change your code to handle the above?  You've got a *lot* of work 
to do if you want a cross platform tool.

I recommend SWIG+CMAKE.  Or my 'mkconfig' tool.



More information about the Digitalmars-d-learn mailing list