I am working on Windows. I have to see certain set of API's for Windows 2008 and above and different set of API's for other flavors of Windows. I want to know what is the best way to design such kind of stuff, so that my main driver code do not have #ifdef
For Example: In Windows 2008 We have API
EVT_HANDLE WINAPI EvtOpenLog(
__in EVT_HANDLE Session,
__in LPCWSTR Path,
__in DWORD Flags
);
and For Windows 2003 we have another API which does the same.
HANDLE OpenEventLog(
__in LPCTSTR lpUNCServerName,
__in LPCTSTR lpSourceName
);
What I am looking for is having some kind of wrapper API in my code which internally handles these calls.
You can write an Platform Abstraction Layer, which will expose a common interface for all api types and for each port then you can implement the interface. You can provide the abstraction as an separate library for each port which ensures that your calling application remains the same only the library to be linked changes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With