gpt4 book ai didi

c++ - 这个 c++ html 整洁程序有什么问题

转载 作者:搜寻专家 更新时间:2023-10-31 00:46:31 26 4
gpt4 key购买 nike

我编译了一个 c tidy 程序,但出现错误,这是他们给出的示例程序

#include "tidy/tidy.h"
#include <stdio.h>
#include <errno.h>


int main(int argc, char **argv )
{
const char* input = "<title>Foo</title><p>Foo!";
TidyBuffer output = {0};
TidyBuffer errbuf = {0};
int rc = -1;
Bool ok;

TidyDoc tdoc = tidyCreate(); // Initialize "document"
printf( "Tidying:\t%s\n", input );

ok = tidyOptSetBool( tdoc, TidyXhtmlOut, yes ); // Convert to XHTML
if ( ok )
rc = tidySetErrorBuffer( tdoc, &errbuf ); // Capture diagnostics
if ( rc >= 0 )
rc = tidyParseString( tdoc, input ); // Parse the input
if ( rc >= 0 )
rc = tidyCleanAndRepair( tdoc ); // Tidy it up!
if ( rc >= 0 )
rc = tidyRunDiagnostics( tdoc ); // Kvetch
if ( rc > 1 ) // If error, force output.
rc = ( tidyOptSetBool(tdoc, TidyForceOutput, yes) ? rc : -1 );
if ( rc >= 0 )
rc = tidySaveBuffer( tdoc, &output ); // Pretty Print

if ( rc >= 0 )
{
if ( rc > 0 )
printf( "\nDiagnostics:\n\n%s", errbuf.bp );
printf( "\nAnd here is the result:\n\n%s", output.bp );
}
else
printf( "A severe error (%d) occurred.\n", rc );

tidyBufFree( &output );
tidyBufFree( &errbuf );
tidyRelease( tdoc );
return rc;
}

错误

构建项目 cr 的配置调试 **

让所有

Building file: ../src/a.cpp
Invoking: GCC C++ Compiler
g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/a.d" -MT"src/a.d" -o"src/a.o" "../src/a.cpp"
../src/a.cpp: In function ‘int main(int, char**)’:
../src/a.cpp:9: error: variable ‘TidyBuffer output’ has initializer but incomplete type
../src/a.cpp:10: error: variable ‘TidyBuffer errbuf’ has initializer but incomplete type
../src/a.cpp:40: error: ‘tidyBufFree’ was not declared in this scope
make: *** [src/a.o] Error 1

最佳答案

TidyBuffer 结构在 Tidy 库头 buffio.h 中声明,因此如果您也包含它,它应该可以工作。

顶部的包含应该如下所示:

#include <tidy.h>
#include <buffio.h>
#include <errno.h>

关于c++ - 这个 c++ html 整洁程序有什么问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5046419/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com