| Symbian开发中想查看Debug信息显得异常麻烦,那么可以在代码中加入如下的Debug模块。从而使Debug信息保存在*.txt文件中。
#define MY_DEBUG #ifdef MY_DEBUG #include <stdio.h> static void MY_TRACK(const char *str) { FILE *fp = fopen("c:\\my_track_char.txt", "a+"); // if (fp == NULL) // { // exit(-1); // } fprintf(fp, "%s\r\n", str); fclose(fp); }
static void MY_TRACK(const TDesC& aMsg) { FILE *fp = fopen("c:\\my_track_desc.txt", "a+"); // if (fp == NULL) // { // exit(-1); // } fwrite(aMsg.Ptr(), sizeof(int), aMsg.Length(), fp); fclose(fp); }
#define MY_TRACK_NUMBER(x, y) {\ FILE *fp = fopen("c:\\my_track_number.txt", "a+"); \ fprintf(fp, "number test: ");\ fprintf(fp, x);\ fprintf(fp, " = ");\ fprintf(fp, "%d\r\n", y);\ fclose(fp); \ }
#else
#include <stdio.h> static void MY_TRACK(const char *str) { }
#define MY_TRACK_NUMBER(x, y) }
#endif
还有两个额外的步骤:
1:修改*.mmp文件,包含以下内容
SYSTEMINCLUDE \epoc32\include\libc
2:在*.mmp文件中加入
LIBRARY estlib.lib
随后会在C:\Symbian\8.0a\S60_2nd_FP2_CW\Epoc32\winscw\c目录下产生调试文本文件。 |