在我的项目中,我需要$(SolutionDir)
在运行时访问宏的值.为此,我尝试添加类似DEBUG_ROOT=$(SolutionDir)
或之前的预处理器条目,DEBUG_ROOT=\"$(SolutionDir)\"
但由于$(SolutionDir)
包含单个\
字符(例如$(SolutionDir) = c:\users\lukas\desktop\sandbox\
),因此由于无效的转义序列而导致各种编译器错误.
有没有一种简单的方法可以将$(SolutionDir)
宏的值传递给我的代码?
我OutputDebugString(..)
在我的调试版本中使用了很多函数来查看我的代码在做什么.
/* debug.h */
#define STRINGIFY(x) #x
#define TOSTRING(x) STRINGIFY(x)
#define LOCATION __FILE__ "(" TOSTRING(__LINE__) ") : "
#if !defined(DEBUG_ROOT)
#define DEBUG_ROOT "#" /* escape string to force strstr(..) to fail */
#endif
/*
** DBGMSG macro setting up and writing a debug string.
** Note: copying the strings together is faster than calling OutputDebugString(..) several times!
** Todo: …
Run Code Online (Sandbox Code Playgroud)