Created
January 10, 2018 05:46
-
-
Save DevHwan/98260448d3bddd3a02697dc2cf1c268e to your computer and use it in GitHub Desktop.
Visual Studio 2015 Legacy Link Error Fix : __imp__iob_fuc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//////////////////////////////////////////////////////////////////////////// | |
//// stdin, stdout, stderr link error for vs2015 | |
//// override implementation of __iob_func | |
//// https://stackoverflow.com/questions/30412951/unresolved-external-symbol-imp-fprintf-and-imp-iob-func-sdl2 | |
#if ( _msc_ver >= 1900 ) | |
#include <cstdio> | |
extern "c" file * __cdecl __iob_func(void) | |
{ | |
struct _iobuf_vs2012 { // ...\microsoft visual studio 11.0\vc\include\stdio.h #56 | |
char *_ptr; | |
int _cnt; | |
char *_base; | |
int _flag; | |
int _file; | |
int _charbuf; | |
int _bufsiz; | |
char *_tmpfname; | |
}; | |
// vs2015 has file = struct {void* _placeholder} | |
static struct _iobuf_vs2012 bufs[3]; | |
static char initialized = 0; | |
if (!initialized) { | |
bufs[0]._ptr = reinterpret_cast<char*>(stdin->_placeholder); | |
bufs[1]._ptr = reinterpret_cast<char*>(stdout->_placeholder); | |
bufs[2]._ptr = reinterpret_cast<char*>(stderr->_placeholder); | |
initialized = 1; | |
} | |
return (file*)&bufs; | |
} | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment