【问题标题】:How to run C program in Visual Studio (Mac)如何在 Visual Studio (Mac) 中运行 C 程序
【发布时间】:2020-01-19 01:46:46
【问题描述】:

所以我第一次尝试使用 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;
}

【问题讨论】:

  • 请更新您的 includePath,

标签: c visual-studio installation vscode-code-runner


【解决方案1】:

在尝试编译之前,必须安装 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/

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-10-03
    • 1970-01-01
    • 1970-01-01
    • 2019-02-28
    • 2022-11-27
    • 2017-05-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多