我正在修改C源文件(libape-spidermonkey.c
)。我包含一個使用某些C++特性的庫頭文件(例如,class definitions
,STL string vector
),所以我必須使用g++
而不是gcc
來編譯libape-spidermonkey.c
。指針鑄造/轉換解決方案將C升級到C++
然而,因爲在C++的類型檢查的,我得到了很多錯誤(不是警告)的:
libape-spidermonkey.c: In function ‘JSBool ape_sm_raw_constructor(JSContext*, JSObject*, uintN, jsval*, jsval*)’:
libape-spidermonkey.c:2217:1: error: invalid conversion from ‘void*’ to ‘ape_sm_compiled*’
libape-spidermonkey.c: In function ‘JSBool ape_sm_sockclient_constructor(JSContext*, JSObject*, uintN,
libape-spidermonkey.c:2231:1: error: invalid conversion from ‘void*’ to ‘ape_sm_compiled*’
libape-spidermonkey.c:2244:38: error: invalid conversion from ‘void*’ to ‘_ape_sock_js_obj*’
libape-spidermonkey.c:2248:53: error: invalid conversion from ‘void*’ to ‘_ape_sock_callbacks*’
libape-spidermonkey.c:2257:36: error: invalid conversion from ‘void*’ to ‘ape_socket*’
libape-spidermonkey.c: In function ‘JSBool ape_sm_pipe_constructor(JSContext*, JSObject*, uintN, jsval*
libape-spidermonkey.c:2281:1: error: invalid conversion from ‘void*’ to ‘ape_sm_compiled*’
libape-spidermonkey.c: In function ‘JSBool ape_sm_sockserver_constructor(JSContext*, JSObject*, uintN,
libape-spidermonkey.c:2585:1: error: invalid conversion from ‘void*’ to ‘ape_sm_compiled*’
libape-spidermonkey.c: In function ‘JSBool ape_sm_xorize(JSContext*, JSObject*, uintN, jsval*, jsval*)’
libape-spidermonkey.c:2632:1: error: invalid conversion from ‘void*’ to ‘ape_sm_compiled*’
libape-spidermonkey.c:2646:31: warning: comparison between signed and unsigned integer expressions
libape-spidermonkey.c:2650:36: error: invalid conversion from ‘void*’ to ‘char*’
有沒有簡單的方法來解決這個問題?像一些宏觀魔法?
謝謝。
Peter
你有什麼樣的g ++選項?你有沒有啓用 - 錯誤 - 牆?如果是,則嘗試禁用此錯誤文件。 – Zuljin 2012-01-12 18:32:51
頭文件中有哪些C++特性?發佈一些有錯誤的代碼。 – 2012-01-12 18:36:02