Relying on the preprocessor and predefined compiler macros to achieve portability is difficult to handle. What is the best way to achieve portability for project C? I want the headers to indicate environment-specific code that behaves the same. Is there a way for the build environment to choose which headers to include?
I thought I put environment-specific headers in directories for specific environments. After that, the build environment will simply copy the headers from the platform directory to the root directory, build the project and delete the copies.
C.
, - make :
INCDIRS=-I ./solaris #INCDIRS=-I ./windows #INCDIRS=-I ./linux : CC=gcc $(INCDIRS) ...
, . :
./solaris/io.h ./windows/io.h ./linux/io.h
, , , solaris.mk windows.mk, - .
solaris.mk
windows.mk
, , , . , , . , #ifdef.
#ifdef
, configure script - , make . GNU autoconf, , , , .
pax , ,
MyFileOpen()
fopen
Source: https://habr.com/ru/post/1741701/More articles:How to launch another application (downloaded or preinstalled) from an event? - androidAndroid application installation history - androidcss menu hover freezes in chrome & safari - cssIs using os.path.abspath to verify the reliable location of an untrusted file name? - pythonUITableViewCells Appear Behind the Background - iphoneserializing JSON files with newlines in Python - jsonMake a card key sorted by insertion sequence - c ++How to check if users submit Arabic words from a form? - javascriptWhat is the difference between Dim s As String and Dim s As [String]? - stringNeed PHP Grid recommendations - phpAll Articles