Reputation:
How might I write a single header file that defines an interface and use a separate source files to write platform-specific code?
For example:
video.h
video_windows.c
video_linux.c
video_osx.c
Upvotes: 4
Views: 4042
Reputation: 133557
In your question you have all header files while you are talking about a shared header between source files.
In any case you just provide a common .h
file and have 3 different
video_windows.c
video_linux.c
video_osx.c
You then include to your makefile (or whatever you use) the correct one according to the platform.
If you want to separate code in header files or in source files directly you can easily use some predefined macros, see here.
Upvotes: 8