www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - Windows bug: _fileno undefined?

reply "Uwe Salomon" <post uwesalomon.de> writes:
If i compile this simple program:


module test;

private import std.c.stdio;

int main(char [][] args)
{

   FILE* f;
   f = fopen("main.d", "r");
   printf("%i\n", fileno(f));
   fclose(f);

   return 0;
}


i get the following error message under windows (dmd 0.127):


obj\test.obj(test)
  Error 42: Symbol undefined _fileno
--- errorlevel 1


But fileno() is defined in std.c.stdio:


version(Win32)
{
   // some code...
   int feof(FILE* fp) { fp._flag & _IOEOF; }
   // some code...
   int fileno(FILE* fp) { return fp._file; }
   // some code...
}


Funny is, if i replace fileno(f) in my program by feof(f), it works. As  
you can see above, feof() is defined only a couple of lines before  
fileno(). So what?

Ciao
uwe
Jun 30 2005
parent reply "Uwe Salomon" <post uwesalomon.de> writes:
 i get the following error message under windows (dmd 0.127):


 obj\test.obj(test)
   Error 42: Symbol undefined _fileno
 --- errorlevel 1

The same goes for _bufsize(), by the way. feof() and ferror() work perfectly. It seems to me that the very simple form of fileno() and _bufsize() produce the problem, they are both like this: int someFunc(void* someStruct) { return someStruct.someMember; } Ciao uwe
Jun 30 2005
parent reply "Regan Heath" <regan netwin.co.nz> writes:
It's especially odd because if you add:

   extern (C) int fileno(FILE *fp) { return fp._file; }

to the top of the source it suddenly starts linking. It even seems to  
produce correct results (prints "3" for me).

Regan

On Thu, 30 Jun 2005 11:24:46 +0200, Uwe Salomon <post uwesalomon.de> wrote:
 i get the following error message under windows (dmd 0.127):


 obj\test.obj(test)
   Error 42: Symbol undefined _fileno
 --- errorlevel 1

The same goes for _bufsize(), by the way. feof() and ferror() work perfectly. It seems to me that the very simple form of fileno() and _bufsize() produce the problem, they are both like this: int someFunc(void* someStruct) { return someStruct.someMember; } Ciao uwe
Jun 30 2005
parent "Uwe Salomon" <post uwesalomon.de> writes:
 It's especially odd because if you add:

    extern (C) int fileno(FILE *fp) { return fp._file; }

 to the top of the source it suddenly starts linking. It even seems to  
 produce correct results (prints "3" for me).
Yep. Somehow the fileno() function is not included in the library, or the linker does not find it...
Jun 30 2005