如何在 Visual Studio (Mac) 中 运行 C 程序

How to run C program in Visual Studio (Mac)

所以我第一次尝试 运行 使用 VS 和 Mac OS Catalina 的 C 程序,但是当我尝试 运行:

#include errors detected. Please update your includePath. Squiggles are disabled for this translation unit (/Users/xxx/Documents/EECS2031/scanf2.c).C/C++(1696)


cannot open source file "stdio.h"C/C++(1696)

我在 VS 中使用 'Code Runner' 扩展到 运行 C 代码,我还使用自制软件安装了以下内容:

xcode-select --install
brew install gcc

我不知道还能做什么,因为我是 C 的新手,搜索后没有找到任何其他解决方案,所以我需要一些帮助。 如果有帮助,c 文件名也有一个 .c 扩展名。

C代码如下:

#include <stdio.h>
/*The error is here when I am trying to include this library*/


int sum (int i, int j)
{
  return i+j;           
}


main()
{
  int a, b;
  printf("Please enter two integers separated by a blank: " );

  scanf( "%d %d",  &a, &b);     /* assign value to a b  */

  printf("Entered %d and %d. Sum is %d\n", a, b, sum(a,b));

  return 0;
}

在尝试编译之前,必须安装 C 环境(所有包含头文件、库等)。

这个网页应该对你有很大帮助:

https://www.tutorialspoint.com/cprogramming/c_environment_setup.htm

特别是段落:

Installation on Mac OS

If you use Mac OS X, the easiest way to obtain GCC is to download the Xcode development environment from Apple's web site and follow the simple installation instructions. 
Once you have Xcode setup, you will be able to use GNU compiler for C/C++.

Xcode is currently available at 

developer.apple.com/technologies/tools/