国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

windows .vscode的json文件配置 CMake 構(gòu)建項(xiàng)目 調(diào)試窗口中文設(shè)置等

這篇具有很好參考價(jià)值的文章主要介紹了windows .vscode的json文件配置 CMake 構(gòu)建項(xiàng)目 調(diào)試窗口中文設(shè)置等。希望對(duì)大家有所幫助。如果存在錯(cuò)誤或未考慮完全的地方,請(qǐng)大家不吝賜教,您也可以點(diǎn)擊"舉報(bào)違法"按鈕提交疑問(wèn)。

一、CMake 和 mingw64的安裝和環(huán)境配置?

windows .vscode的json文件配置 CMake 構(gòu)建項(xiàng)目 調(diào)試窗口中文設(shè)置等,CMake 筆記,vscode,cmake,tasks.json,launch.json,中文亂碼

windows .vscode的json文件配置 CMake 構(gòu)建項(xiàng)目 調(diào)試窗口中文設(shè)置等,CMake 筆記,vscode,cmake,tasks.json,launch.json,中文亂碼

windows .vscode的json文件配置 CMake 構(gòu)建項(xiàng)目 調(diào)試窗口中文設(shè)置等,CMake 筆記,vscode,cmake,tasks.json,launch.json,中文亂碼

二、tasks.json和launch.json文件配置

  • tasks.json
{
    "version": "2.0.0",
    "options": {
        "cwd": "${workspaceFolder}/build"
    },
    "tasks": [
        {
            "type": "shell",
            "label": "cmake",
            "command": "cmake",
            "args": [
                ".."
            ]
        },
        {
            "label": "make",
            "group": "build",
            "command": "make",
            "args": [],
            "problemMatcher": []
        },
        {
            "label": "Build",
            "dependsOrder": "sequence",
            "dependsOn": [
                "cmake",
                "make"
            ]
        },
        {
            "type": "cppbuild",
            "label": "C/C++: g++ 生成活動(dòng)文件",
            // "command": "/usr/bin/g++",
            "command": "D://mingw64//bin//g++.exe",
            "args": [
                "-fdiagnostics-color=always",
                "-g",
                "-o",
                "${workspaceFolder}/bin/app.exe",
                "-fexec-charset=GBK"
            ],
            "options": {
                "cwd": "${workspaceFolder}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "detail": "D://mingw64//bin//g++.exe"
        }
    ]
}
  • launch.json
{
    // 使用 IntelliSense 了解相關(guān)屬性。 
    // 懸停以查看現(xiàn)有屬性的描述。
    // 欲了解更多信息,請(qǐng)?jiān)L問(wèn): https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "(gdb) 啟動(dòng)",
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceFolder}/bin/app.exe",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": true,
            "MIMode": "gdb",
            "setupCommands": [
                {
                    "description": "為 gdb 啟用整齊打印",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                },
            ],
            "preLaunchTask": "Build",
            "miDebuggerPath": "D://mingw64//bin//gdb.exe", // 修改為你的 gdb 路徑
        },
    ]
}

?三、CMakeLists.txt文件

cmake_minimum_required(VERSION 3.15)
project(Cat)

# C++ 的解決辦法
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fexec-charset=GBK")

include_directories(${PROJECT_SOURCE_DIR}/include)
aux_source_directory(${PROJECT_SOURCE_DIR}/src SRC_LIST)
# 添加可執(zhí)行文件
add_executable(app main.cpp ${SRC_LIST})
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)

四、頭文件和源文件

  • cat.h
#ifndef CAT_H
#define CAT_H
#include <iostream>
#include <string>
class Cat{
public:
    Cat(std::string name, int age); // 構(gòu)造函數(shù),初始化姓名和年齡
    // Getter
    std::string getName () const;
    int getAge() const;
    // Setter
    void setName(std::string name);
    void setAge(int age);
    // print
    void printObj() const;
    ~Cat();
private:
    std::string m_name; // 姓名
    int m_age; // 年齡
};
#endif
  • cat.cpp
#include "cat.h"
Cat::Cat(std::string name, int age) {
    this->m_name = name;
    this->m_age = age;
}

std::string Cat::getName() const{
    return this->m_name;
}

int Cat::getAge() const{
    return this->m_age;
}

void Cat::setName(std::string name) {
    this->m_name = name;
}

void Cat::setAge(int age) {
    this->m_age = age;
}

void Cat::printObj() const{
    std::cout << "Cat(" << this << ")" << ": Name : " << this->m_name << ": Age : " << this->m_age << std::endl;
}

Cat::~Cat() {
    std::cout<<"析構(gòu)函數(shù)~"<<std::endl;
}
  • main.cpp
#include <iostream>
#include "cat.h"
using namespace std;

int main(int argc,char *argv[]) {
    // 值
    Cat cat1("moon",3);         
    // const Cat cat1("moon",3);
    // const Obj 只能調(diào)用 const Method
    cout<<cat1.getName()<<endl;
    cout<<cat1.getAge()<<endl;
    cat1.printObj();
    cat1.setName("黑貓警長(zhǎng)");    
    cout<<cat1.getName()<<endl;

    // 指針
    const Cat *catPoint = &cat1;
    cout<<catPoint->getName()<<endl;
    cout<<catPoint->getAge()<<endl;
    catPoint->printObj();

    // 引用
    const Cat &catRef = cat1;
    cout<<catRef.getName()<<endl;
    cout<<catRef.getAge()<<endl;
    catRef.printObj();
    system("pause");
    return 0;
}

五、中文亂碼問(wèn)題解決

?CMake C/C++程序輸出亂碼
Clion CMake C/C++程序輸出亂碼_cmake message 亂碼-CSDN博客https://blog.csdn.net/qq_37274323/article/details/120674592

# C的解決辦法
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -fexec-charset=GBK")
# C++ 的解決辦法
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fexec-charset=GBK")

在此基礎(chǔ)上,進(jìn)一步來(lái)解決?VScode控制臺(tái)中文亂碼問(wèn)題?(文章推薦)

(4 封私信 / 25 條消息) 如何解決VScode控制臺(tái)中文亂碼問(wèn)題? - 知乎 (zhihu.com)https://www.zhihu.com/question/65557618/answer/2950382369?utm_id=0

  • 在tasks.json文件中添加:"-fexec-charset=GBK"

windows .vscode的json文件配置 CMake 構(gòu)建項(xiàng)目 調(diào)試窗口中文設(shè)置等,CMake 筆記,vscode,cmake,tasks.json,launch.json,中文亂碼

  • 接著,在設(shè)置中搜索"encoding",啟用Auto Guess Encoding?

windows .vscode的json文件配置 CMake 構(gòu)建項(xiàng)目 調(diào)試窗口中文設(shè)置等,CMake 筆記,vscode,cmake,tasks.json,launch.json,中文亂碼

windows .vscode的json文件配置 CMake 構(gòu)建項(xiàng)目 調(diào)試窗口中文設(shè)置等,CMake 筆記,vscode,cmake,tasks.json,launch.json,中文亂碼

五、運(yùn)行方式

方式一:1.先點(diǎn)擊生成,可以生成所選目標(biāo)

windows .vscode的json文件配置 CMake 構(gòu)建項(xiàng)目 調(diào)試窗口中文設(shè)置等,CMake 筆記,vscode,cmake,tasks.json,launch.json,中文亂碼

2.點(diǎn)擊運(yùn)行按鈕,在終端窗口中啟動(dòng)所選目標(biāo)?

windows .vscode的json文件配置 CMake 構(gòu)建項(xiàng)目 調(diào)試窗口中文設(shè)置等,CMake 筆記,vscode,cmake,tasks.json,launch.json,中文亂碼

方式二:按住F5運(yùn)行,會(huì)出現(xiàn)調(diào)試窗口和終端窗口,也可以看變量等

windows .vscode的json文件配置 CMake 構(gòu)建項(xiàng)目 調(diào)試窗口中文設(shè)置等,CMake 筆記,vscode,cmake,tasks.json,launch.json,中文亂碼文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-820436.html

到了這里,關(guān)于windows .vscode的json文件配置 CMake 構(gòu)建項(xiàng)目 調(diào)試窗口中文設(shè)置等的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來(lái)自互聯(lián)網(wǎng)用戶投稿,該文觀點(diǎn)僅代表作者本人,不代表本站立場(chǎng)。本站僅提供信息存儲(chǔ)空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請(qǐng)注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實(shí)不符,請(qǐng)點(diǎn)擊違法舉報(bào)進(jìn)行投訴反饋,一經(jīng)查實(shí),立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費(fèi)用

相關(guān)文章

覺(jué)得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請(qǐng)作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包