[英]Can Catch2 be used with C language?
我正在編寫一個 dll,它支持與 C 和 C++ 語言應用程序的接口。 The dll itself is written in C++, so the question is can i use Catch2 framework for unittesting both C and C++ applications?
我需要注意什么? 有沒有人可以建議的替代方案?
測試必須用 C++ 編寫。
要測試 function,您只需要能夠調用它。 因此,問題等同於“可以從 C++ 調用 C 函數嗎?”。
在大多數情況下,答案是肯定的。 有一個“語言鏈接”功能就是為了這個目的。 C 不兼容的一些例外情況,例如名稱為 C++ 關鍵字的函數,如delete
。 To call such function, you would need to write a wrapper function in C, with a compatible name and call that wrapper from the test written in C++.
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.