I am trying to read this line it is in the c code of legacy dll visual studio project , But I can't understand it
_fmemcpy((LPSTR FAR *)Defdat,(LPSTR FAR *)&DLLdat,sizeof(DATSETTING));
I am compiling for windows 64 bit visual studio 2010
libraries
#include <stdio.h>
#include <string.h>
#include <windows.h>
#include <time.h>
Thanks
Back in the days of 16-bit windows, pointers could either be 16-bit pointers inside a data segment, or they could store both the 16-bit segment selector and a 16-bit address within that segment. The term for the latter kind of pointer was FAR, and any kind of pointer passed between different modules, such as the main program and the OS or a DLL, had to use them. So did all but the smallest real-world programs, which if nothing else used different segments for the heap and the stack. LPSTR is Hungarian notation for long pointer to string, so I think this programmer was being redundant.
There used to be separate versions of some library functions for FAR pointers, and that was the version of memcpy()
that copied data between different segments on 16-bit Windows. To help port code over, it became a macro on 32-bit Windows that expands to memcpy()
, and LPSTR
expands to char *
. FAR is just ignored.