HelloWorld C++:访问桌面文件夹的神秘请求

问题描述 投票:0回答:2

按照此处的说明,我在 Mac OS 11.6 和 VS code 1.61.2 下构建并执行了以下代码。代码未修改自 https://code.visualstudio.com/docs/cpp/config-clang-mac

#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main()
{
    vector<string> msg {"Hello", "C++", "World", "from", "VS Code", "and the C++ extension!"};

    for (const string& word : msg)    {
        cout << word << " ";
    }
    cout << endl;
}

执行时,Mac OS 会弹出以下意外问题: “helloworld 想要访问桌面上的文件的权限。”当被拒绝时,程序退出,没有抱怨,也没有输出。当直接从命令行执行时,helloworld 会打印预期的输出,并且不会显示奇怪的行为。

到底是什么?我没有碰任何文件!我的 C++ 库是否被恶意软件损坏了?还有其他人见过这种奇怪的行为吗?

我终于答应了,它就不再问了。我应该改变主意吗?我该去哪里这样做?

c++ macos visual-studio-code permissions desktop
2个回答
1
投票

谢谢你,Alan Birtles,将其祖父母文件夹从桌面移至另一个位置解决了该消息等问题。


0
投票

将代码保留在应用程序文件夹中,它不会再次询问

© www.soinside.com 2019 - 2024. All rights reserved.