How to auto-include all headers in directory

前端 未结 10 3209
被撕碎了的回忆
被撕碎了的回忆 2021-02-20 12:32

I\'m going through exercises of a C++ book. For each exercise I want to minimize the boilerplate code I have to write. I\'ve set up my project a certain way but it doesn\'t seem

10条回答
  •  情深已故
    2021-02-20 12:58

    writing a makefile rule to pass the name of the executable as a -DHEADERFILE=something parameter to the compiler shouldn't be difficult at all. Something like:

    %.exe : %.h %.cpp main.cpp
        gcc -o $< -DHEADER_FILE=$
    

    OTOH, I don't know if #include does macro expansion on the filename.

提交回复
热议问题