0

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. When executed directly from the command line, helloworld prints the expected output and does not show the strange behavior.

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

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

Joymaker
  • 813
  • 1
  • 9
  • 23
  • not a macos user, but maybe this helps: ["" would to access your files](https://stackoverflow.com/questions/61394972/program-would-like-to-access-files-in-your-documents-folder-message-with-v) - [related github issue](https://github.com/microsoft/vscode-cpptools/issues/5282) – Turtlefight Oct 29 '21 at 17:01
  • 2
    is the program stored on your desktop by any chance? – Alan Birtles Oct 29 '21 at 17:05
  • Before going further, use a virus scanner hopefully to rule that out. Takes just a minute for peace of mind. Then, as @AlanBirtles suggests, investigate where it is running - also investigate where your VScode is installed. My guess is that VSCode is inserting something "convenient" into your exe. – RMiller Oct 29 '21 at 17:28
  • @RMiller vs code is a glorified text editor, it wont be doing anything to the executable – Alan Birtles Oct 29 '21 at 17:38
  • i think MacOS just doesnt like "using namespace std;". – jwezorek Oct 29 '21 at 18:26
  • Please contact Apple support – Osyotr Oct 29 '21 at 19:56

1 Answers1

0

Thank you, Alan Birtles, moving its grandparent folder off the desktop to another location solved the message and more.

Joymaker
  • 813
  • 1
  • 9
  • 23