From 36dc1d06343c5552cbda2049a8833cfc3838cfbd Mon Sep 17 00:00:00 2001 From: Avi Kivity <avi@cloudius-systems.com> Date: Thu, 10 Jan 2013 11:37:47 +0200 Subject: [PATCH] file: don't overide FILE Unlike most glibc data types, FILE is not opaque - it is defined as _IO_FILE in libio.h and some glibc inlines actually use it. So we must use the same structure. Do this by subclassing _IO_FILE. Unbreaks mode=release build. --- libc/file.cc | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/libc/file.cc b/libc/file.cc index c8795e393..97d0b90e7 100644 --- a/libc/file.cc +++ b/libc/file.cc @@ -1,6 +1,3 @@ -#define __FILE_defined -class FILE; - #include <stdio.h> #include <fcntl.h> #include <string.h> @@ -9,12 +6,10 @@ class FILE; #include "libc.hh" #include "fs/fs.hh" -class FILE { +class std_file : public _IO_FILE { public: - explicit FILE(int fd); - ~FILE(); -private: - int _fd; + explicit std_file(int fd); + ~std_file(); }; class __dirstream { @@ -26,9 +21,9 @@ private: fileref _file; }; -FILE::FILE(int fd) - : _fd(fd) +std_file::std_file(int fd) { + _fileno = fd; } __dirstream::__dirstream(fileref file) @@ -63,7 +58,7 @@ FILE* fopen(const char* fname, const char* fmode) if (fd == -1) { return nullptr; } - return new FILE(fd); + return new std_file(fd); } DIR* opendir(const char* fname) -- GitLab