2011-02-13 40 views
2

我從ubuntu存儲庫安裝了tidy-dev,檢查了安裝路徑 - 沒關係(/ usr/include/tidy)。如何使用html tidy編譯C++程序C++

但我不能找到一個真正的標誌來編譯我的C++腳本包括http://users.rcn.com/creitzel/tidy/tidyx.h

整潔C++包裝tidyx.h你能幫助我嗎?

我的測試腳本文件名爲1.cpp,tidyx.h我放在附近。 1.cpp內容:

#include "tidyx.h" 

int main() 
{ 
} 

我嘗試,但沒有良好:

$ gcc -I/usr/include/tidy 1.cpp -ltidy 

In file included from 1.cpp:1: 
tidyx.h: In constructor ‘Tidy::Source::Source()’: 
tidyx.h:83: error: invalid conversion from ‘int (*)(ulong)’ to ‘int (*)(void*)’ 
tidyx.h:84: error: invalid conversion from ‘void (*)(ulong, byte)’ to ‘void (*)(void*, byte)’ 
tidyx.h:85: error: invalid conversion from ‘Bool (*)(ulong)’ to ‘Bool (*)(void*)’ 
tidyx.h:86: error: invalid conversion from ‘ulong’ to ‘void*’ 
tidyx.h: In constructor ‘Tidy::Sink::Sink()’: 
tidyx.h:123: error: invalid conversion from ‘void (*)(ulong, byte)’ to ‘void (*)(void*, byte)’ 
tidyx.h:124: error: invalid conversion from ‘ulong’ to ‘void*’ 
tidyx.h: In member function ‘void Tidy::Buffer::Attach(void*, uint)’: 
tidyx.h:165: error: invalid conversion from ‘void*’ to ‘byte*’ 
tidyx.h:165: error: initializing argument 2 of ‘void tidyBufAttach(TidyBuffer*, byte*, uint)’ 
tidyx.h: In member function ‘int Tidy::Document::Create()’: 
tidyx.h:496: error: invalid conversion from ‘ulong’ to ‘void*’ 
tidyx.h:496: error: initializing argument 2 of ‘void tidySetAppData(const _TidyDoc*, void*)’ 
tidyx.h: In member function ‘void Tidy::Document::SetAppData(ulong)’: 
tidyx.h:511: error: invalid conversion from ‘ulong’ to ‘void*’ 
tidyx.h:511: error: initializing argument 2 of ‘void tidySetAppData(const _TidyDoc*, void*)’ 
tidyx.h: In member function ‘ulong Tidy::Document::GetAppData()’: 
tidyx.h:512: error: invalid conversion from ‘void*’ to ‘ulong’ 
+0

什麼是錯誤信息?在黑暗中拍攝會讓你忘記鏈接到整潔的圖書館(你只包括它的標題)? –

回答

1

要包括你需要使用#include預處理指令的頭文件。它將在編譯器包含路徑中查找頭文件。

如果tidyx.h/usr/include/tidy你可以把你的源文件:

#include <tidy/tidyx.h> 

,然後用gcc script.cpp剛剛編譯,因爲/usr/include是最有可能是默認包括爲你的編譯路徑。

否則,你也可以把你的源文件:

#include <tidyx.h> 

然後告訴GCC看在/usr/include/tidygcc -I/usr/include/tidy script.cpp

此時頭部會被發現。如果您還會遇到與整潔有關的其他錯誤(例如:某些整理函數未定義),則需要使用GCC -l選項將您的二進制文件鏈接到某個庫。


OP龐大的編輯後,編輯

這裏你的問題是,tidyx.h包含C++代碼,並且你的源文件,看它的擴展,似乎是一個C++源文件。您需要一個C++編譯器才能編譯它。使用g++代替gcc

g++ script.cpp 
+0

謝謝,我知道它。我重寫了這個問題。 – Arturgspb

+0

@ user614999:更新了我的回答 – peoro

+0

您的意思是「g ++ -I/usr/include/tidy 1.cpp」? – Arturgspb