How to create a function declaration?
Sean Kelly
sean at f4.ca
Fri Jan 12 15:05:27 PST 2007
Tyler Knott wrote:
> Sean Kelly wrote:
>> This one has bitten me a few times where I had declared the prototype
>> for a C library routine to avoid importing the entire header module,
>> and a derived module imported both my module and the C header module.
>> Even worse, the same error will occur if one of the two declarations
>> is private, because of how symbol resolution is handled. This makes
>> the approach outlined above completely intractable, and actually more
>> restrictive than C where multiple prototypes of the same function are
>> allowed.
>
> What's wrong with importing the entire header module? That's what
> modules are designed for: avoiding declaring the same function multiple
> times. They also don't add any code bloat.
In the past, there were some issues with D where importing even empty
modules bloated the executable quite noticeably (I think it was ~500
bytes per empty module). This appeared related to ModuleInfo that was
generated apparently regardless of whether it was necessary. I
re-tested this recently, however, and was unable to reproduce my old
results, so I think this problem has been fixed as a side-effect of
other changes. Still, there are some places in my code where I have
declarations of C routines rather than imports, as I haven't gone to the
trouble of changing them now that this seems to have been resolved.
Sean
More information about the Digitalmars-d-learn
mailing list