Function prototype + definition in the same file

Timon Gehr timon.gehr at gmx.ch
Tue Sep 25 16:29:06 PDT 2012


On 09/25/2012 01:53 PM, Manu wrote:
> So I have this recurring pattern, it's really starting to annoy me.
> It stems from the fact that a function prototype and the definition can
> not appear in the same file in D (as it can in C/C++)
> Eg,
>
> void func(int x); // <-- declaration of function, informs type and
> associated names, args, ...
>
> //later
> void func(int x) // <-- may be generated with magic (and may use the
> prototype declaration for type information as declared by the prototype
> above)
> {
>    ... do stuff
> }
>
> I really need this. Why is it illegal? Is there chance of having this
> supported? What are the problems?
> ...

It is illegal because nobody has written code to support it. It
should be possible to support it. I don't think there are any problems
with the concept.


More information about the Digitalmars-d mailing list