[英]C++20 compiling modules with Visual Studio: doesn't compile or import ixx files
Visual Studio 2019 不會嘗試編譯 my.cxx 或 .ixx 文件。 這是我的.cxx 文件:
export module greetings;
import std.core;
export std::string get_greeting_text()
{
return "Hello, World!";
}
這是主要的:
import std.core;
import greetings;
int main()
{
std::cout << get_greeting_text() << '\n';
}
我確實設置了這些標志: /std:c++latest
, /experimental:module
。 錯誤消息是
C:\...\main.cpp(2,17):error C2230: could not find module 'greetings'
C:\...\main.cpp(6,2): error C3861: 'get_greeting_text': identifier not found
...但是我沒有看到任何關於嘗試編譯 greetings.cxx 的行,所以這一定是問題所在。 將其更改為 .ixx 無效。 解決方法是什么?
解決方案:
它似乎有點片狀。 除非我先進行清理,否則重建失敗。
模塊聲明export module greetings;
尚未在 Visual Studio 2019 上工作。
您可以嘗試為您的 greetings.cxx 文件添加以下編譯器意見:
/module:export /module:name greetings /module:wrapper greetings.h /module:output greetings.ifc -c greetings.cxx
另一種解決方案,將 greetings.cxx 重命名為 greetings.ixx。 Visual Studio 中的模塊接口文件需要 .ixx 擴展名。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.