whats wrong with this c++ html tidy program
i have compiled an c tidy program i am getting an error and it is an example program given by them
#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};
i开发者_JAVA百科nt 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;
}
error
Build of configuration Debug for project cr **
make all
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
The TidyBuffer struct is declared in the Tidy library header buffio.h
, so if you include that as well it should work.
Includes at the top should then look like this:
#include <tidy.h>
#include <buffio.h>
#include <errno.h>
精彩评论