locked
expected a declaration RRS feed

  • Question

  • when I wrote the code to set up vscode (.json):

    {
    	"version": "2.0.0",
    	"tasks": [
    		{
    			"type": "shell",
    			"label": "C/C++: g++.exe build active file",
    			"command": "C:\\Program Files (x86)\\mingw-w64\\i686-8.1.0-posix-dwarf-rt_v6-rev0\\mingw32\\bin\\g++.exe",
    			"args": [
    				"-g",
    				"${file}",
    				"-o",
    				"${fileDirname}\\${fileBasenameNoExtension}.exe"
    			],
    			"options": {
    				"cwd": "C:\\Program Files (x86)\\mingw-w64\\i686-8.1.0-posix-dwarf-rt_v6-rev0\\mingw32\\bin"
    			},
    			"problemMatcher": [
    				"$gcc"
    			],
    			"group": "build"
    		}
    	]
    }

    and it gives an error: expected a declaration.

    I don't understand why this error is happening, especially when the system reports the error at {at the top and elsewhere.

    and:

    {
        // 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": "C/C++: Build and debug active file",
                "type": "cppdbg",
                "request": "launch",
                "program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
                "args": [],
                "stopAtEntry": false,
                "cwd": "${workspaceFolder}",
                "environment": [],
                "externalConsole": true,
                "MIMode": "gdb",
                "miDebuggerPath": "C:\\Program Files (x86)\\mingw-w64\\i686-8.1.0-posix-dwarf-rt_v6-rev0\\mingw32\\bin\\gdb.exe",
                "setupCommands": [
                    {
                        "description": "Enable pretty-printing for gdb",
                        "text": "-enable-pretty-printing",
                        "ignoreFailures": true
                    }
                ],
                "preLaunchTask": "C/C++: g++.exe build active file"
            }
        ]
    }

    that is similar to the launch.json file, and with this code, it highlights the following half

    Sunday, November 8, 2020 12:43 PM

All replies

  • Questions

    • Which IDE e.g. VS2019 or VS Code?
    • Where does this file reside?

    Be very specific, a long reply is much better than a short reply else we need to ask many more questions to you.


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    My GitHub code samples
    GitHub page

    Sunday, November 8, 2020 4:35 PM
  • Vs Code.

    I created this file to assist in compiling, located in the .vscode folder. I tried several things but couldn't handle it, even just by writing "{" it was an error.

    at line (7,5)  I also got the error "Match multiple schemas when there is only one schema to validate.", this error corresponds to yellow.

    I write about c ++



    • Edited by Hào Ca Monday, November 9, 2020 12:55 PM
    Monday, November 9, 2020 12:51 PM
  • Hi ,

    This does not seem to be a programming problem, but a problem of using VS code.

    So I think you'd better raise this issue in the VS code GitHub repository.

    The Visual C# forum discusses and asks questions about the C# programming language, IDE, libraries, samples, and tools.

    Best Regards,

    Timon


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, November 10, 2020 7:59 AM