D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 7729 - fileno conflict
Summary: fileno conflict
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: All All
: P2 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-03-18 08:59 UTC by Jacob Carlborg
Modified: 2017-07-10 12:47 UTC (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Jacob Carlborg 2012-03-18 08:59:31 UTC
"fileno" declared in std.stdio conflicts with the one declared in core.stdc.stdio. Removing the following line should fix the problem: 

https://github.com/D-Programming-Language/phobos/blob/master/std/stdio.d#L38
Comment 1 AndyC 2015-01-25 19:09:22 UTC
I'm not sure how to test this.  Is this a good test?

// file test.d:
import std.stdio;
import core.stdc.stdio;

void main()
{
    File f = File("test.d", "r");
    writeln( f.fileno() );
}

This compiles and runs fine.  

Is this still a problem?  Can you post some sample code?
Comment 2 Jacob Carlborg 2015-01-25 19:58:10 UTC
(In reply to AndyC from comment #1)

> Is this still a problem?  Can you post some sample code?

import std.stdio;
import core.stdc.stdio;

void main ()
{
    FILE* f;
    fileno(f);
}

The error message I get:

main.d(7,11): Error: core.stdc.stdio.fileno at ~/.dvm/compilers/dmd-2.066.1/osx/bin/../../src/druntime/import/core/stdc/stdio.d(773,10) conflicts with core.sys.posix.stdio.fileno at ~/.dvm/compilers/dmd-2.066.1/osx/bin/../../src/druntime/import/core/sys/posix/stdio.d(192,8)

So actually now it's a conflict between core.stdc.stdio and core.sys.posix.stdio.
Comment 3 Steven Schveighoffer 2015-01-26 13:19:06 UTC
So maybe this is Posix only?

I'm curious actually, how come these conflict? Both are extern(C), so they are pointing at the same symbol.
Comment 4 Jacob Carlborg 2015-01-26 17:52:48 UTC
(In reply to Steven Schveighoffer from comment #3)
> So maybe this is Posix only?
> 
> I'm curious actually, how come these conflict? Both are extern(C), so they
> are pointing at the same symbol.

Yeah, but does the compiler know that? Or rather, I don't think it uses different rules for looking up symbols depending on if they're extern(C).
Comment 5 AndyC 2015-01-27 03:38:16 UTC
This code compiles fine on windows:

import std.stdio;
import core.stdc.stdio;

void main ()
{
    FILE* f;
    fileno(f);
}
Comment 6 Steven Schveighoffer 2015-01-27 04:04:27 UTC
(In reply to AndyC from comment #5)
> This code compiles fine on windows:

Right, because Windows does not import or declare anything via core.sys.posix. The bug is posix-only (there isn't a drop-down for that though).
Comment 7 RazvanN 2017-07-10 12:22:28 UTC
Cannot reproduce on Ubuntu 16.04 with latest dmd.
Comment 8 Steven Schveighoffer 2017-07-10 12:47:44 UTC
The alias was removed here: https://github.com/dlang/phobos/pull/2809

So it was actually fixed before Jacob's test in January of 2015, but hadn't made it into the released compiler yet.