C++ &引用;“未找到标识符”;Windows中有错误,但Mac中没有

C++ &引用;“未找到标识符”;Windows中有错误,但Mac中没有,c++,qt,C++,Qt,当我试图在Windows中编译我的程序时,我有一个在mac中运行良好的函数,但出现了一个错误: std::string myMainWindow::getPlansPath() { char cwd[1024]; if (getcwd(cwd, sizeof(cwd)) != NULL) { printf("Current working dir: %s\n", cwd); } else { perror("getcwd() error")

当我试图在Windows中编译我的程序时,我有一个在mac中运行良好的函数,但出现了一个错误:

std::string myMainWindow::getPlansPath() {
    char cwd[1024];
    if (getcwd(cwd, sizeof(cwd)) != NULL) {
        printf("Current working dir: %s\n", cwd);
    } else {
        perror("getcwd() error");
    }

    std::string path = std::string(cwd) + std::string("/myfolder");

    return path;
}
错误:

C:\path\to\project\gui\myMainWindow.cxx(876):错误C3861:'getcwd':找不到标识符
忍者:构建停止:子命令失败。
可能是什么

更新:


我最终使用的是
QDir::currentPath()
,这正是我想要的。

是UNIX特有的函数,它在Windows中不存在,它属于
库这一事实很好地说明了这一点。一个可能的解决方案是使用,尽管我不熟悉它的用途,我通过MSDN页面收集,这或多或少是一样的。

您必须在
窗口上的
标题中使用
\u getcwd
标题,因为这是为
Qt
框架标记的:一个
c++17
选项是: