How to create a function declaration?
Stewart Gordon
smjg_1998 at yahoo.com
Fri Jan 12 11:26:07 PST 2007
Marcio Faustino wrote:
<snip>
> /*[ test.d ]*******************************************************************/
> import my_printf;
>
> void main() {
> //printf("test\0"); // Error.
> my_printf.printf("test\0"); // Ok.
> }
> /******************************************************************************/
>
> Because the line with "Error" uncommented, the compiler says:
> «test.d(5): Error: object.printf at /home/marcio/dmd/src/phobos/object.d(14)
> conflicts with my_printf.printf at my_printf.d(3)»
You've more or less answered your own question: use a fully-qualified
name. Alternatively, use in test.d
alias my_printf.printf printf;
However, when doing it on functions with C linkage, you have to be
careful. Because they don't have the module name mangled in, you may
cause a linker conflict or end up inadvertently calling the C library
function with the same name. Indeed, I don't know why this doesn't
cause a linker conflict when I try it (under DMD 1.00, Win98SE).
Stewart.
More information about the Digitalmars-d-learn
mailing list