Construct path for #include directive with macro

后端 未结 4 863
耶瑟儿~
耶瑟儿~ 2020-11-27 07:54

I would like to have include file paths dynamically created by a macro for a target-configuration-dependent part of my program.

for example, I would like to construc

4条回答
  •  北荒
    北荒 (楼主)
    2020-11-27 08:19

    This works for VS2013. (It can be done easier, ofcourse.)

    #define myIDENT(x) x
    #define myXSTR(x) #x
    #define mySTR(x) myXSTR(x)
    #define myPATH(x,y) mySTR(myIDENT(x)myIDENT(y))
    
    #define myLIBAEdir D:\\Georgy\\myprojects\\LibraryAE\\build\\native\\include\\ //here whitespace!
    #define myFile libae.h
    
    #include myPATH(myLIBAEdir,myFile)
    

提交回复
热议问题