.di "header" files

e-t172 idontlikespam at nospam.com
Wed Nov 14 03:24:04 PST 2007


Hello,

I'm a bit confused about what the -H option of the DMD compiler (or the
-fintfc of the GDC compiler) actually does. As a matter of fact, I think
of it as a way to automatically generate the equivalent of .h files in
D, which contains only declarations, not the actual code.

So, considering the following code:

module ditest;

import std.stdio;

class Foo
{
         void bar()
         {
                 // Moo.
                 writefln("Hello World !");
         }
}

If I compile that with the -H (or the -fintfc) option (dmd -c -H
ditest.d), I would expect to find something like this in the 
automatically generated .di file:

// D import file generated from 'test.d'
module ditest;
class Foo
{
     void bar();
}

But instead, here is what DMD generates (GDC does the same):

// D import file generated from 'test.d'
module ditest;
import std.stdio;
class Foo
{
     void bar()
{
writefln("Hello World !");
}
}

I must say I don't understand how this is useful : all it did was strip
comments and whitespaces. It didn't strip the body of the bar() 
function, which is what was expected.

So is this normal, if it is, what is the real purpose of the -H option, 
and otherwise, how do I make it work correctly ?

Regards,



More information about the Digitalmars-d mailing list