C/C++
新建C/C++文件
比如来一个Helloworld.cpp
然后里面写上如下代码:
#include<iostream>
using namespace std;
int main()
{
cout<<"HelloWorld Mac"<<endl;
return 0;
}
紧接着就运行你这个cpp文件,VS code会报错,让你安装拓展,装!让你配置task.json文件,你就复制黏贴下面的代码
配置task.json
该代码来自VS code官网的官方文档:Using Clang in Visual Studio Code
这个task.json文件在.vscode文件夹中
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"label": "clang++ build active file",
"command": "/usr/bin/clang++",
"args": [
"-std=c++17",
"-stdlib=libc++",
"-g",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}"
],
"options": {
"cwd": "${workspaceFolder}"
},
"problemMatcher": ["$gcc"],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
然后再次点击调试,选择环境clang++,紧接着你就要配置launch.json文件
配置launch.json文件
该代码来自VS code官网的官方文档:Using Clang in Visual Studio Code
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "clang++ - Build and debug active file",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}/${fileBasenameNoExtension}",
"args": [],
"stopAtEntry": true,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "lldb",
"preLaunchTask": "clang++ build active file"
}
]
}
然后你就可以运行cpp文件,一般是没有什么问题了
出现“检测到#include错误,请更新includepath”的错误的时候做法
第一步:打开终端,输入一下代码看g++包含路径
g++ -v -E -x c++ -
第二步:复制如图所示区域:
第三步:在.vscode文件夹下面新建一个文件:c_cpp_properties.json,注意后缀也要!
第四步,输入如下代码,在指定区域添加路径
{
"configurations": [
{
"name": "Mac",
"includePath": [
"${workspaceFolder}/**",
],
"defines": [],
"macFrameworkPath": [],
"cStandard": "c17",
"cppStandard": "c++17",
"intelliSenseMode": "macos-gcc-x64"
}
],
"version": 4
}
在
“includePath”: [
“${workspaceFolder}/**”,
这里加上你的路径
]
下面给个示例
{
"configurations": [
{
"name": "Mac",
"includePath": [
"${workspaceFolder}/**",
"/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1",
"/Library/Developer/CommandLineTools/usr/lib/clang/13.0.0/include",
"/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include",
"/Library/Developer/CommandLineTools/usr/include",
"/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks"
],
"defines": [],
"macFrameworkPath": [],
"cStandard": "c17",
"cppStandard": "c++17",
"intelliSenseMode": "macos-gcc-x64"
}
],
"version": 4
}
这样子之后就能解决问题了
JAVA
到官网下载JDK
终端输入:java -version
如果有安装JDK,应该会显示这个信息
如果没有,请移步官网下载,我这里直接贴出下载地址:jdk-16.0.1_osx-x64_bin.dmg
VS code 安装拓展
新建一个文件:Helloworld.java
然后写入以下代码:
public class Helloworld {
public static void main(String[] args) {
System.out.println("Hello WorldMacBook");
System.out.println("ssssss");
}
}
//注意文件名和class后面的类名要一致
运行!
报错,安装拓展,装!
接下来,直接傻瓜化操作
下载傻瓜化配置包
我直接贴链接:Coding Pack for Java
这个包是vs code的人出的一个配置包(听说是),打开之后会自动帮你配置Java环境,然后安装好了之后就开始写你的Java吧
总结
可能我的某些地方有错误,多上网查,上网参考,大不了就remake,希望大家都能成功!