c++ - fread fails with VS2008 64-bits -


i'm porting software 32 64-bits using visual studio 2008 , i'm encountering issue regarding fread causes segfault when called:

here code sample reproducing issue:

void somefunction(std::string filepath) {     file* myfile = fopen(filepath.c_str(),"rb"); // returns valid handle     if (myfile)     {         char* buffer = new char[buffer_size+1];         memset(buffer,0,buffer_size+1);         fread(buffer,1,buffer_size,myfile); // segfault happens here         fclose(f);     } } 

geterror , ferror not report error , file can read when compiling 32-bits. triggers segfault when entering fread on 64-bits though.

i've tried several other file reading methods (with ifstream , qt's qfile) , work.

unfortunately, fread used in many other places in code , know if there peculiar implementation vs2008 64-bit before changing every bit of code uses it.

thanks in advance.

ok guys think figured out.

seems issue related msvcrt linking on debug mode.

the fread call located inside library linked against msvcrtd.lib while executable error raised linked against msvcrt.

i'm kind of surprised causing issues fread. libc symbols located inside msvcrt under windows ?

anyway, i'm cleaning link flags. sorry not have been able post more detailed code sample. working under strict ndas , did not excpect related link flags ^^'


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -