在我自己的项目中使用tidy-html5静态库进行编译

时间:2016-09-04 14:57:47

标签: c tidy htmltidy

我试图在我的项目中添加tidy-html5库。首先,我创建一个名为“clean.c”的文件,只包含两个包含:

#include <tidy.h>
#include <tidybuffio.h>

我使用了libtidys.a文件,并将其复制到项目的libs目录中。

所以我编译了这个文件:

$ gcc -ansi -pedantic -std=c99 -c -W -Wall -O -I/foo/bar/inc -I/usr/include/libxml2 -I/foo/bar/dependencies/tidy-html5/include -L/foo/bar/libs -ltidys clean.c -o clean.o

以下是结果:

In file included from /foo/bar/dependencies/tidy-html5/include/tidy.h:65:0,
             from clean.c:1:
/foo/bar/dependencies/tidy-html5/include/tidyplatform.h:547:9: error: unknown type name 'uint'
 typedef uint tchar;         /* single, full character */
         ^
In file included from clean.c:1:0:
/foo/bar/dependencies/tidy-html5/include/tidy.h:368:13: error: unknown type name 'uint'
 TIDY_EXPORT uint TIDY_CALL        tidyErrorCount( TidyDoc tdoc );
             ^
/foo/bar/dependencies/tidy-html5/include/tidy.h:371:13: error: unknown type name 'uint'
 TIDY_EXPORT uint TIDY_CALL        tidyWarningCount( TidyDoc tdoc );
             ^
/foo/bar/dependencies/tidy-html5/include/tidy.h:374:13: error: unknown type name 'uint'
 TIDY_EXPORT uint TIDY_CALL        tidyAccessWarningCount( TidyDoc tdoc );
             ^
/foo/bar/dependencies/tidy-html5/include/tidy.h:377:13: error: unknown type name 'uint'
 TIDY_EXPORT uint TIDY_CALL        tidyConfigErrorCount( TidyDoc tdoc );
             ^
/foo/bar/dependencies/tidy-html5/include/tidy.h:469:13: error: unknown type name 'ulong'
 TIDY_EXPORT ulong TIDY_CALL         tidyOptGetDefaultInt( TidyOption opt );
            ^
/foo/bar/dependencies/tidy-html5/include/tidy.h:487:13: error: unknown type name 'ulong'
 TIDY_EXPORT ulong TIDY_CALL         tidyOptGetInt( TidyDoc tdoc, TidyOptionId optId );
             ^
/foo/bar/dependencies/tidy-html5/include/tidy.h:489:86: error: unknown type name 'ulong'
 TIDY_EXPORT Bool TIDY_CALL          tidyOptSetInt( TidyDoc tdoc, TidyOptionId optId, ulong val );
                                                                                      ^
/foo/bar/dependencies/tidy-html5/include/tidy.h:594:13: error: unknown type name 'uint'
 TIDY_EXPORT uint TIDY_CALL tidyGetByte( TidyInputSource* source );
             ^
/foo/bar/dependencies/tidy-html5/include/tidy.h:597:68: error: unknown type name 'uint'
 TIDY_EXPORT void TIDY_CALL tidyUngetByte( TidyInputSource* source, uint byteValue );
                                                                ^
/foo/bar/dependencies/tidy-html5/include/tidy.h:631:63: error: unknown type name 'uint'
 TIDY_EXPORT void TIDY_CALL tidyPutByte( TidyOutputSink* sink, uint byteValue );
                                                           ^
/foo/bar/dependencies/tidy-html5/include/tidy.h:643:44: error: unknown type name 'uint'
   uint line, uint col, ctmbstr mssg );
   ^
/foo/bar/dependencies/tidy-html5/include/tidy.h:643:55: error: unknown type name 'uint'
   uint line, uint col, ctmbstr mssg );
   ^
/foo/bar/dependencies/tidy-html5/include/tidy.h:646:44: error: unknown type name 'uint'
    uint line, uint col, ctmbstr mssg, va_list args );
    ^
/foo/bar/dependencies/tidy-html5/include/tidy.h:646:55: error: unknown type name 'uint'
   uint line, uint col, ctmbstr mssg, va_list args );
   ^
/foo/bar/dependencies/tidy-html5/include/tidy.h:649:49: error: unknown type name 'uint'
    uint line, uint col, ctmbstr code, va_list args );
    ^
/foo/bar/dependencies/tidy-html5/include/tidy.h:649:60: error: unknown type name 'uint'
   uint line, uint col, ctmbstr code, va_list args );
   ^
/foo/bar/dependencies/tidy-html5/include/tidy.h:653:51: error: unknown type name 'TidyReportFilter'
   TidyReportFilter filtCallback );
   ^
/foo/bar/dependencies/tidy-html5/include/tidy.h:656:51: error: unknown type name 'TidyReportFilter2'
   TidyReportFilter2 filtCallback );
   ^
/foo/bar/dependencies/tidy-html5/include/tidy.h:659:56: error: unknown type name 'TidyReportFilter3'
   TidyReportFilter3 filtCallback );
   ^
/foo/bar/dependencies/tidy-html5/include/tidy.h:675:57: error: unknown type name 'uint'
  typedef void (TIDY_CALL *TidyPPProgress)( TidyDoc tdoc, uint line, uint col, uint destLine );
                                                          ^
/foo/bar/dependencies/tidy-html5/include/tidy.h:675:68: error: unknown type name 'uint'
  typedef void (TIDY_CALL *TidyPPProgress)( TidyDoc tdoc, uint line, uint col, uint destLine );
                                                           ^
/foo/bar/dependencies/tidy-html5/include/tidy.h:675:78: error: unknown type name 'uint'
  typedef void (TIDY_CALL *TidyPPProgress)( TidyDoc tdoc, uint line, uint col, uint destLine );
                                                          ^
/foo/bar/dependencies/tidy-html5/include/tidy.h:678:51: error: unknown type name 'TidyPPProgress'
TidyPPProgress callback );
^
/foo/bar/dependencies/tidy-html5/include/tidy.h:756:65: error: unknown type name 'uint'
tmbstr buffer, uint* buflen );
               ^
/foo/bar/dependencies/tidy-html5/include/tidy.h:908:13: error: unknown type name 'uint'
  TIDY_EXPORT uint TIDY_CALL tidyNodeLine( TidyNode tnod );
              ^
/foo/bar/dependencies/tidy-html5/include/tidy.h:909:13: error: unknown type name 'uint'
  TIDY_EXPORT uint TIDY_CALL tidyNodeColumn( TidyNode tnod );
              ^
In file included from clean.c:2:0:
/foo/bar/dependencies/tidy-html5/include/tidybuffio.h:27:5: error: unknown type name 'uint'
 uint  size;         /**< # bytes currently in use */
 ^
/foo/bar/dependencies/tidy-html5/include/tidybuffio.h:28:5: error: unknown type name 'uint'
 uint  allocated;    /**< # bytes allocated */ 
 ^
/foo/bar/dependencies/tidy-html5/include/tidybuffio.h:29:5: error: unknown type name 'uint'
 uint  next;         /**< Offset of current input position */
 ^
/foo/bar/dependencies/tidy-html5/include/tidybuffio.h:40:59: error: unknown type name 'uint'
 TIDY_EXPORT void TIDY_CALL tidyBufAlloc( TidyBuffer* buf, uint allocSize );
                                                           ^
/foo/bar/dependencies/tidy-html5/include/tidybuffio.h:46:55: error: unknown type name 'uint'
 uint allocSize );
 ^
/foo/bar/dependencies/tidy-html5/include/tidybuffio.h:52:47: error: unknown type name 'uint'
 uint allocSize, uint chunkSize );
 ^
/foo/bar/dependencies/tidy-html5/include/tidybuffio.h:52:63: error: unknown type name 'uint'
 uint allocSize, uint chunkSize );
 ^
/foo/bar/dependencies/tidy-html5/include/tidybuffio.h:61:70: error: unknown type name 'uint'
TIDY_EXPORT void TIDY_CALL tidyBufAttach( TidyBuffer* buf, byte* bp, uint size );
^
/foo/bar/dependencies/tidy-html5/include/tidybuffio.h:68:70: error: unknown type name 'uint'
 TIDY_EXPORT void TIDY_CALL tidyBufAppend( TidyBuffer* buf, void* vp, uint size );
                                                                      ^
Makefile:16: recipe for target 'clean.o' failed
make[1]: *** [clean.o] Error 1
Makefile:26: recipe for target 'all' failed
make: *** [all] Error 1

所以我做了一个快速检查,我注意到tidy.h文件包含“tidyplatform.h”,其中包含:

#if defined(BE_OS) || defined(SOLARIS_OS) || defined(BSD_BASED_OS) || defined(OSF_OS) || defined(IRIX_OS) || defined(AIX_OS)
#include <sys/types.h>
#endif
#if !defined(HPUX_OS) && !defined(CYGWIN_OS) && !defined(MAC_OS_X) && !defined(BE_OS) && !defined(SOLARIS_OS) && !defined(BSD_BASED_OS) && !defined(OSF_OS) && !defined(IRIX_OS) && !defined(AIX_OS) && !defined(LINUX_OS)
# undef uint
typedef unsigned int uint;
#endif
#if defined(HPUX_OS) || defined(CYGWIN_OS) || defined(MAC_OS) || defined(BSD_BASED_OS) || defined(_WIN32)
# undef ulong
typedef unsigned long ulong;
#endif

我在GNU / Linux上。所以我想我可以通过在第一个预处理器指令中添加“defined(LINUX_OS)”来解决这个问题(我没试过)。但是,这很奇怪,因为这个库被大量使用所以...我错过了什么?

干杯

0 个答案:

没有答案