Cross-Platform C++ code and single header - multiple implementations

前端 未结 5 616
离开以前
离开以前 2021-01-31 11:15

I have heard that a way to write Cross Platform c++ code is to define classes as follows (for example, a Window class):

window.h
window_win32.cpp
window_linux.cp         


        
5条回答
  •  灰色年华
    2021-01-31 11:44

    Most of the time, you avoid such things in the header. There are times, however, when you want to expose them. In such cases, my solution has always been to use something like:

    #include dependentInclude(syst,MyInclude.lhh)
    

    dependentInclude being a macro which expands to the the path of the file I need, depending on the value of syst (which was set on the command line).

提交回复
热议问题