-
-
Notifications
You must be signed in to change notification settings - Fork 273
Closed
Description
This program:
import std.stdio;
void main() {
auto f = File("testfile.tmp", "wb+");
ubyte[4] buffer = [1, 2, 3, 4];
f.rawWrite(buffer);
f.seek(0);
f.rawRead(buffer);
writeln(buffer);
}fails to build, emitting the error:
$ ldmd2 ldcio.d
G:/Programs/LDC/include/d\std\stdio.d(665): Error: undefined identifier '_fileno', did you mean 'function fileno'?
G:/Programs/LDC/include/d\std\stdio.d(666): Error: undefined identifier '_setmode'
G:/Programs/LDC/include/d\std\stdio.d(666): Error: undefined identifier _O_BINARY
G:/Programs/LDC/include/d\std\stdio.d(667): Error: undefined identifier '_setmode'
ldcio.d(7): Error: template instance std.stdio.File.rawWrite!(ubyte) error instantiating
The build succeeds and runs correctly using DMD:
$ dmd ldcio.d && ldcio.exe
[1, 2, 3, 4]
I ran into the problem with DMD when building for 64 bit (the bugreport for it is (located here)[http://d.puremagic.com/issues/show_bug.cgi?id=10227], and my hackey fix was to replace these lines (117-138) of stdio.d:
else version (MICROSOFT_STDIO)
{
extern (C)
{
/* **
* Microsoft under-the-hood C I/O functions
*/
int _fputc_nolock(int, _iobuf*);
int _fputwc_nolock(int, _iobuf*);
int _fgetc_nolock(_iobuf*);
int _fgetwc_nolock(_iobuf*);
void _lock_file(FILE*);
void _unlock_file(FILE*);
}
alias _fputc_nolock FPUTC;
alias _fputwc_nolock FPUTWC;
alias _fgetc_nolock FGETC;
alias _fgetwc_nolock FGETWC;
alias _lock_file FLOCK;
alias _unlock_file FUNLOCK;
}With:
else version (MICROSOFT_STDIO)
{
extern (C)
{
/* **
* Microsoft under-the-hood C I/O functions
*/
int _fputc_nolock(int, _iobuf*);
int _fputwc_nolock(int, _iobuf*);
int _fgetc_nolock(_iobuf*);
int _fgetwc_nolock(_iobuf*);
void _lock_file(FILE*);
void _unlock_file(FILE*);
int _setmode(int, int);
int _fileno(FILE*);
}
alias _fputc_nolock FPUTC;
alias _fputwc_nolock FPUTWC;
alias _fgetc_nolock FGETC;
alias _fgetwc_nolock FGETWC;
alias _lock_file FLOCK;
alias _unlock_file FUNLOCK;
enum _O_BINARY = 0x8000;
}With this "fix" (I'm not sure how stable it is), both DMD and LDC compile and run as expected.
Reactions are currently unavailable