如何在程序中自动判断? 我记得可以设置的。
8 个解决方案
#1
有个_Debug 宏
#2
#ifdef _DEBUG
输出一些东西
#endif
输出一些东西
#endif
#3
#ifdef _DEBUG
#endif
#4
代码中经常会看到
#ifdef _DEBUG
#endif
这个就是用于确定是调试还是发行模式的
#5
#ifdef _DEBUG
TRACE("Debug");
#endif
TRACE("Debug");
#endif
#6
File: "C:\Program Files\Microsoft Visual Studio\VC98\MFC\Include\AFX.H" 52 occurrences found on 52 lines
205: /////////////////////////////////////////////////////////////////////////////
206: // Diagnostic support
207:
208: #ifdef _DEBUG
209:
210: BOOL AFXAPI AfxAssertFailedLine(LPCSTR lpszFileName, int nLine);
211:
212: void AFX_CDECL AfxTrace(LPCTSTR lpszFormat, ...);
213: // Note: file names are still ANSI strings (filenames rarely need UNICODE)
214: void AFXAPI AfxAssertValidObject(const CObject* pOb,
215: LPCSTR lpszFileName, int nLine);
216: void AFXAPI AfxDump(const CObject* pOb); // Dump an object from CodeView
217:
218: #define TRACE ::AfxTrace
219: #define THIS_FILE __FILE__
220: #define ASSERT(f) \
221: do \
222: { \
223: if (!(f) && AfxAssertFailedLine(THIS_FILE, __LINE__)) \
224: AfxDebugBreak(); \
225: } while (0) \
226:
227: #define VERIFY(f) ASSERT(f)
228: #define ASSERT_VALID(pOb) (::AfxAssertValidObject(pOb, THIS_FILE, __LINE__))
229: #define DEBUG_ONLY(f) (f)
230:
231: // The following trace macros are provided for backward compatiblity
232: // (they also take a fixed number of parameters which provides
233: // some amount of extra error checking)
234: #define TRACE0(sz) ::AfxTrace(_T("%s"), _T(sz))
235: #define TRACE1(sz, p1) ::AfxTrace(_T(sz), p1)
236: #define TRACE2(sz, p1, p2) ::AfxTrace(_T(sz), p1, p2)
237: #define TRACE3(sz, p1, p2, p3) ::AfxTrace(_T(sz), p1, p2, p3)
238:
239: // These AFX_DUMP macros also provided for backward compatibility
240: #define AFX_DUMP0(dc, sz) dc << _T(sz)
241: #define AFX_DUMP1(dc, sz, p1) dc << _T(sz) << p1
242:
243: #else // _DEBUG
244:
245: #define ASSERT(f) ((void)0)
246: #define VERIFY(f) ((void)(f))
247: #define ASSERT_VALID(pOb) ((void)0)
248: #define DEBUG_ONLY(f) ((void)0)
249: inline void AFX_CDECL AfxTrace(LPCTSTR, ...) { }
250: #define TRACE 1 ? (void)0 : ::AfxTrace
251: #define TRACE0(sz)
252: #define TRACE1(sz, p1)
253: #define TRACE2(sz, p1, p2)
254: #define TRACE3(sz, p1, p2, p3)
255:
256: #endif // !_DEBUG
#7
一直RELEASE
#8
在VS2010中的工具栏有个文本框,显示debug或release,选择即可。
#1
有个_Debug 宏
#2
#ifdef _DEBUG
输出一些东西
#endif
输出一些东西
#endif
#3
#ifdef _DEBUG
#endif
#4
代码中经常会看到
#ifdef _DEBUG
#endif
这个就是用于确定是调试还是发行模式的
#5
#ifdef _DEBUG
TRACE("Debug");
#endif
TRACE("Debug");
#endif
#6
File: "C:\Program Files\Microsoft Visual Studio\VC98\MFC\Include\AFX.H" 52 occurrences found on 52 lines
205: /////////////////////////////////////////////////////////////////////////////
206: // Diagnostic support
207:
208: #ifdef _DEBUG
209:
210: BOOL AFXAPI AfxAssertFailedLine(LPCSTR lpszFileName, int nLine);
211:
212: void AFX_CDECL AfxTrace(LPCTSTR lpszFormat, ...);
213: // Note: file names are still ANSI strings (filenames rarely need UNICODE)
214: void AFXAPI AfxAssertValidObject(const CObject* pOb,
215: LPCSTR lpszFileName, int nLine);
216: void AFXAPI AfxDump(const CObject* pOb); // Dump an object from CodeView
217:
218: #define TRACE ::AfxTrace
219: #define THIS_FILE __FILE__
220: #define ASSERT(f) \
221: do \
222: { \
223: if (!(f) && AfxAssertFailedLine(THIS_FILE, __LINE__)) \
224: AfxDebugBreak(); \
225: } while (0) \
226:
227: #define VERIFY(f) ASSERT(f)
228: #define ASSERT_VALID(pOb) (::AfxAssertValidObject(pOb, THIS_FILE, __LINE__))
229: #define DEBUG_ONLY(f) (f)
230:
231: // The following trace macros are provided for backward compatiblity
232: // (they also take a fixed number of parameters which provides
233: // some amount of extra error checking)
234: #define TRACE0(sz) ::AfxTrace(_T("%s"), _T(sz))
235: #define TRACE1(sz, p1) ::AfxTrace(_T(sz), p1)
236: #define TRACE2(sz, p1, p2) ::AfxTrace(_T(sz), p1, p2)
237: #define TRACE3(sz, p1, p2, p3) ::AfxTrace(_T(sz), p1, p2, p3)
238:
239: // These AFX_DUMP macros also provided for backward compatibility
240: #define AFX_DUMP0(dc, sz) dc << _T(sz)
241: #define AFX_DUMP1(dc, sz, p1) dc << _T(sz) << p1
242:
243: #else // _DEBUG
244:
245: #define ASSERT(f) ((void)0)
246: #define VERIFY(f) ((void)(f))
247: #define ASSERT_VALID(pOb) ((void)0)
248: #define DEBUG_ONLY(f) ((void)0)
249: inline void AFX_CDECL AfxTrace(LPCTSTR, ...) { }
250: #define TRACE 1 ? (void)0 : ::AfxTrace
251: #define TRACE0(sz)
252: #define TRACE1(sz, p1)
253: #define TRACE2(sz, p1, p2)
254: #define TRACE3(sz, p1, p2, p3)
255:
256: #endif // !_DEBUG
#7
一直RELEASE
#8
在VS2010中的工具栏有个文本框,显示debug或release,选择即可。