vscode c_cpp_properties setting

vscode c_cpp_properties setting

C/C++ 插件用户工程项目配置

.vscode/c_cpp_properties.json 增加如下内容:

{
    "version": 4,
    "configurations": [
        {
            "name": "mingw-w64-x86_64",
            "intelliSenseMode": "gcc-x64",
            "defines": [
                "DEBUG",
                "_DEBUG",
                "_DEBUG_CDB",
                "UNICODE",
                "_UNICODE",
                "_FORTIFY_SOURCE=1",
                "CHECK_PTHREAD_RETURN_VALUE",
                "_FILE_OFFSET_BITS=64",
                "_LARGEFILE64_SOURCE",
                "LARGEFILE_SOURCE",
                "__cdecl=__attribute__((__cdecl__))"
            ],
            "includePath": [
                "${workspaceRoot}\\\\src",
                "${workspaceRoot}\\\\inc",
                "C:\\\\msys64\\\\mingw64\\\\include",
                "C:\\\\msys64\\\\mingw64\\\\include\\\\c++\\\\9.2.0\\\\backward",
                "C:\\\\msys64\\\\mingw64\\\\include\\\\c++\\\\9.2.0",
                "C:\\\\msys64\\\\mingw64\\\\x86_64-w64-mingw32\\\\include",
                "C:\\\\msys64\\\\mingw64\\\\lib\\\\gcc\\\\x86_64-w64-mingw32\\\\9.2.0\\\\include-fixed",
                "C:\\\\msys64\\\\mingw64\\\\lib\\\\gcc\\\\x86_64-w64-mingw32\\\\9.2.0\\\\include"
            ],
            "browse": {
                "path": [
                    "${workspaceRoot}\\\\src",
                    "${workspaceRoot}\\\\inc",
                    "C:\\\\msys64\\\\mingw64\\\\include",
                    "C:\\\\msys64\\\\mingw64\\\\include\\\\c++\\\\9.2.0\\\\backward",
                    "C:\\\\msys64\\\\mingw64\\\\include\\\\c++\\\\9.2.0",
                    "C:\\\\msys64\\\\mingw64\\\\x86_64-w64-mingw32\\\\include",
                    "C:\\\\msys64\\\\mingw64\\\\lib\\\\gcc\\\\x86_64-w64-mingw32\\\\9.2.0\\\\include-fixed",
                    "C:\\\\msys64\\\\mingw64\\\\lib\\\\gcc\\\\x86_64-w64-mingw32\\\\9.2.0\\\\include"
                ],
                "limitSymbolsToIncludedHeaders": true,
                "databaseFilename": ""
            },
            "windowsSdkVersion": "10.0.17134.0",
            "compilerPath": "C:\\\\msys64\\\\mingw64\\\\bin\\\\g++.exe",
            "cStandard": "c11",
            "cppStandard": "c++17"
        }
    ]
}

-----------------------------------

.vscode/launch.json 增加如下内容:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "C++ Launch (GDB)",
            "type": "cppdbg",
            "request": "launch",
            "program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": true,
            "MIMode": "gdb",
            "miDebuggerPath": "C:\\msys64\\mingw64\\bin\\gdb.exe",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ],
            "preLaunchTask": "CppCompile"
        }
    ]
}

.vscode/tasks.json 增加如下内容:

{
    "version": "2.0.0",
    "tasks": [
        {
            "type": "shell",
            "label": "CppCompile",
            "command": "C:\\msys64\\mingw64\\bin\\g++.exe",
            "args": [
                "-g",
                "-Og",
                "-Wall",
                "-static-libgcc",
                "-std=c++17",
                "${file}",
                "-o",
                "${fileDirname}\\${fileBasenameNoExtension}.exe"
            ],
            "options": {
                "cwd": "C:\\msys64\\mingw64\\bin"
            },
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "presentation": {
                "echo": true,
                "reveal": "always",
                "focus": false,
                "panel": "shared",
                "showReuseMessage": true,
                "clear": false
            },
            "problemMatcher": "$gcc"
        }
    ]
}

------------------------------------

Code-Runner 插件用户全局配置

C:\Users\LSGX\AppData\Roaming\Code\User\settings.json 增加如下内容:

    "code-runner.runInTerminal": true,
    "code-runner.ignoreSelection": true,
    "code-runner.executorMap": {
        "c": "cd $dir && gcc $fileName -o $fileNameWithoutExt.exe -Wall -g -Og -static-libgcc -std=c11 && $dir$fileNameWithoutExt.exe",
        "cpp": "cd $dir && g++ $fileName -o $fileNameWithoutExt.exe -Wall -g -Og -static-libgcc -std=c++17 && $dir$fileNameWithoutExt.exe"
    }

----------------------------------------

C++ 编译器支持情况表 https://zh.cppreference.com/w/cpp/compiler_support

--------------------------------------

查看 gcc 配置信息 echo | gcc -v -x c -E -
查看 g++ 配置信息 echo | gcc -v -x c++ -E -
查看 g++ 配置信息 echo | g++ -v -x c++ -E -

--------------------------

注意: mingw32 不支持wWinMain作为程序入口,需要将wWinMain改为WinMain 。

C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/msys64/mingw64/x86_64-w64-mingw32/lib//libmingw32.a(lib64_libmingw32_a-crt0_c.o): in function `main‘:
E:/mingwbuild/mingw-w64-crt-git/src/mingw-w64/mingw-w64-crt/crt/crt0_c.c:18: undefined reference to `WinMain‘
collect2.exe: error: ld returned 1 exit status

via https://stackoverflow.com/questions/58324230/undefined-reference-to-winmain-c-mingw

One thing to note is that Visual C++ supports a “wWinMain” entry point where the “lpCmdLine” parameter is a “LPWSTR”. You would typically use the “_tWinMain” preprocessor definition for your entry point and declare “LPTSTR lpCmdLine” so that you can easily support both ANSI and Unicode builds. However, the MinGW CRT startup library does not support wWinMain, so you’ll have to stick with the standard “WinMain” and use “GetCommandLine()” if you need to access command line arguments.

Use WinMain instead. This program doesn‘t use pCmdLine value, so it should compile when you change wWinMain to WinMain and PWSTR pCmdLine to PSTR pCmdLine.

via https://docs.microsoft.com/en-us/windows/win32/learnwin32/prepare-your-development-environment
via https://www.transmissionzero.co.uk/computing/win32-apps-with-mingw/

================ End

原文地址:https://www.cnblogs.com/lsgxeva/p/12122271.html

时间: 2024-11-05 18:44:18

vscode c_cpp_properties setting的相关文章

同步vscode的setting.json和extensions

vc 详情 $ npm i -g vscode-config $ vc config --token <your github token> $ vc config --id <your gist id> $ vc push 拉取 $ vc pull 原文地址:https://www.cnblogs.com/ajanuw/p/12287786.html

VSCode中C/C++库文件的配置

之前一直在是用sublime做主要编辑器,现在主要使用VSCode,毕竟大厂制作,从目前的使用情况来看,我更喜欢使用VSCode编辑器. 有时候会用VScode来组件C/C++工程,并且用到了一些外部依赖的库文件,比如OpenCV.此时希望VSCode的代码提示功能能够提示OpenCV中的函数,这时候就需要配置工作空间中的C/C++编译环境. 如果你使用过sublime或者VSCode,就知道Ctrl+Shift+P可以调出控制窗口,那么先按下Ctrl+Shift+P: 再输入edit或者con

6.20-Param reconfig讨论

参考前言工作步骤坐标修正学习dynamic configdynamic reconfig具体技术Service Call-Based Re-configuration 实践 TOC 参考 ROS WIKI dynamic_reconfigure 前言 因为windows平台的ROS for LV 没有显式支持action,所以不能直接给move_base节点发送move_base/cancel (actionlib_msgs/GoalID),故在ROS端添加一个Proxy来代理解决 该代理的功能

可选链plugin-proposal-optional-chaining的使用

第一步 安装 npm install --save-dev @babel/plugin-proposal-optional-chaining 然后在.babelrc.js文件夹里进行配置 plugins:"@babel/plugin-proposal-optional-chaining", vscode好像不太支持这种语法,所以得在vscode的setting中配置 "javascript.validate.enable": false, 接下来就可以使用了 大概用

vscode setting.json

setting.json { "sync.gist": "#github的码##", "sync.lastUpload": "2018-08-26T06:45:07.435Z", "sync.autoDownload": false, "sync.autoUpload": false, "sync.lastDownload": "2018-05-15T06:

vscode setting.jsonxx

// Place your settings in this file to overwrite the default settings { "files.autoGuessEncoding": true, "files.associations": { "*.wxss": "css", "*.wxml": "html" }, "emmet.syntaxProfiles&qu

折腾Vscode写C++

一直以来都是用Sublime Text3写C/C++.因为ST配置简单,轻量.闲来没事才弄一弄. 1. 新建文件夹C++Code,并且再建立一个bulid文件夹来放要写的代码. ? 2. 在Vscode里新建.vscode文件夹,建立上图的3个文件(setting不需要) 2.1 Launch.json { "version": "0.2.0", "configurations": [ { "name": "C++

VSCode编写C/C++语言,配置文件和注意事项

前言 主要是自己先下载好VSCode,然后在自己电脑上安装好就行了,但是VSCode是编辑器,不是IDE,所以需要自己配置文件,主要有四个都是以.json结尾的文件,这里默认已经装过C/C++的编辑器,也就意味着电脑上有MINGW64,也就说明你自己先要找到他们的路径为后续配置做好准备. 把gcc.exe,gdb.exe的路径添加到环境变量里面,也就是MINGW64的bin目录. 开始打开一个文件夹,在VSCode中打开一个文件夹,然后创建一个cpp程序.再点开调试栏,然后生成文件.或者自己创建

VsCode使用基础

Visual Studio Code(以下简称vscode)是一个轻量且强大的代码编辑器,支持Windows,OS X和Linux.内置JavaScript.TypeScript和Node.js支持,而且拥有丰富的插件生态系统,可通过安装插件来支持C++.C#.Python.PHP等其他语言. 在做LuaIde插件的时候发现很多第一次接触VsCode 的同学会问一些基础问题 为了不必要的时间浪费,写下这个简单介绍: 这里是作者的插件--> LuaIde LuaIde是用于Lua语言编辑.首先它是