【问题标题】:unable to print output to stdout within sources of libxml2无法在 libxml2 的源中将输出打印到标准输出
【发布时间】:2020-06-27 06:26:53
【问题描述】:

我想调试 libxml2 的源代码,为此,我想在某些函数中打印一些语句。 但是,如下所示的打印语句不会在控制台中产生任何结果

我已将它们放在文件 xmlschemas.c 和函数 xmlSchemaParse 中

xmlSchemaPtr
xmlSchemaParse(xmlSchemaParserCtxtPtr ctxt)
{
    xmlSchemaPtr mainSchema = NULL;
    xmlSchemaBucketPtr bucket = NULL;
    int res;
#ifdef fprintf
#undef fprintf
#endif

#ifdef printf
#undef printf
#endif
    printf("HELLO WORLD\n");
    fprintf(stderr, "HERE");
    fflush(stderr);

...

任何与此有关的指针表示赞赏

【问题讨论】:

    标签: c libxml2


    【解决方案1】:

    这与系统库 /usr/lib/libxml2.dylib 在执行期间优先于本地库有关

    因此我的代码没有被提取。

    设置加载动态库相关的环境变量后更改生效

    【讨论】:

      【解决方案2】:

      关于:

      #ifdef fprintf
      #undef fprintf
      #endif
      
      #ifdef printf
      #undef printf
      #endif
      
      printf("HELLO WORLD\n");
      fprintf(stderr, "HERE");
      

      注意:那些undef 宏对来自libc6.so 库而不是来自任何xml 库的函数printf()fprintf() 没有影响。

      您没有看到调用printf() 和调用fprintf() 的结果是因为发布的代码从未执行过(甚至可能没有链接到您的程序)。

      要执行这些“替代”功能:

      1. 它们必须被编译
      2. 它们必须在标准 xml 库之前链接

      因此,请发布您的编译语句和链接语句。然后我们可以提供进一步的帮助。

      【讨论】:

        猜你喜欢
        • 2018-12-25
        • 2013-05-01
        • 1970-01-01
        • 2017-09-08
        • 1970-01-01
        • 2015-08-31
        • 1970-01-01
        • 2018-08-10
        • 1970-01-01
        相关资源
        最近更新 更多