Jump to content

HelloWorld C++: mysterious request to access desktop folder


Recommended Posts

Following instructions here, I built and executed the following code under Mac OS 11.6 and VS code 1.61.2. Code unmodified from 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;
}

When it executes, Mac OS pops up with the following unexpected question: "helloworld wants permission to access files on the desktop." When denied, the program exited without complaint and without output and reference from this blog post. When executed directly from the command line, helloworld prints the expected output and does not show the strange behaviour.

What the heck? I touched no files! Is my C++ library corrupted with malware? Has anyone else seen this odd behaviour?

I finally said yes and it quit asking. Should I change my mind? And where would I go to do so?

 
Link to post
Share on other sites

This probably has something to do with VS code. Are you running the code from the desktop? If so, that's likely to be why. If you run it from the command line, most likely the Terminal app already has those permissions, thus you don't see the alert. You can revoke the permissions given in this way in System Preferences -> Security & Privacy -> Privacy -> Files and Folders and/or Full Disk Access.

It's definitely not anything malware-related, though, so I'd encourage you to ask for clarification on a VS forum for Mac users.

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
Back to top
×
×
  • Create New...

Important Information

This site uses cookies - We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.