Coder Social home page Coder Social logo

danielpinto8zz6 / c-cpp-compile-run Goto Github PK

View Code? Open in Web Editor NEW
118.0 5.0 28.0 4.48 MB

:wrench: Compile & Run single c/c++ files easly on vscode

Home Page: https://marketplace.visualstudio.com/items?itemName=danielpinto8zz6.c-cpp-compile-run

License: GNU General Public License v3.0

TypeScript 92.18% Handlebars 3.78% JavaScript 4.05%

c-cpp-compile-run's Introduction

Logo

C/C++ Compile Run extension

Buy Me A Coffee Support via PayPal

Visual Studio Marketplace Version Visual Studio Marketplace Downloads Visual Studio Marketplace Rating Open VSX Version Open VSX Downloads Open VSX Rating

An extension running on Visual Studio Code to Compile, Run & Debug single c/c++ files easily

Extension

Features

Compile, Run & Debug C/C++ opened file directly from the command palette, by pressing 'f6', 'f7', 'f5', or by using status bar/menu icons.

Requirements

How to use

Make sure you have .c or .cpp file open. Press "F6", this will compile and run the file using default arguments in settings. If you press "F7", this will use the arguments you specify for the program. You can also debug by pressing "F5". Or you can use the status bar/menu items.

If you want to register gcc/g++ path manually, you can set it under settings. You can also set to save file before compiling.

Configurations

Key Description
c-cpp-compile-run.c-compiler The C compiler path (e.g: /usr/bin/gcc or C:\TDM-GCC-64\bin\gcc.exe)
c-cpp-compile-run.cpp-compiler The Cpp compiler path (e.g: /usr/bin/g++ C:\TDM-GCC-64\bin\gcc.exe)
c-cpp-compile-run.save-before-compile Whether should save the file before compiling
c-cpp-compile-run.c-flags The C flags: e.g. -Wall. default: -Wall -Wextra -g3
c-cpp-compile-run.cpp-flags The Cpp flags: e.g. -Wall. default: -Wall -Wextra -g3
c-cpp-compile-run.run-args The run arguments
c-cpp-compile-run.run-in-external-terminal Whether should run in an external terminal
c-cpp-compile-run.should-show-notifications Whether should show notifications
c-cpp-compile-run.output-location Custom output location for the compiled file
c-cpp-compile-run.custom-run-prefix Prefix command before run (e.g: valgrind ./foobar)

Keybindings

Linux Windows Mac Description
f6 f6 cmd+r Compiles and runs the file
crtl+6 ctrl+6 cmd+6 Compiles and runs the file
f8 f8 cmd+y Compiles and run the file in external console
f7 f7 cmd+t Compiles and run the file specifying custom arguments and flags
f5 f5 cmd+5 Debugs the file (includes compile)

Release Notes

Refer to CHANGELOG

c-cpp-compile-run's People

Contributors

66leo66 avatar andylizf avatar aprilnea avatar danielpinto8zz6 avatar dependabot-preview[bot] avatar dependabot[bot] avatar github-actions[bot] avatar lazyren avatar lhyphen avatar mapleccc avatar msaaddev avatar rivinhd avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

c-cpp-compile-run's Issues

C++ Version Select

Would be cool if a feature is added where you could select what version to compile in such as c++11 , c++14, c++17 etc

Add more setup information for new users

I have installed this extension in linux and it works flawlessly but today i installed it in windows 10 . Now i cant make it run when pressing f6/f7. I have setup environment path in windows settings but it still doesnt work , plz help

Invalid compiler path

I'm using MinGW for my copiler and even tough I set the g++ and/or gcc paths to the MinGW folder, it still tells me the compiler path is invalid, what do I do?
a
b

Error compiling

image

I am trying to switch from code blocks to VS Code but I am getting a compile error. Also the past issues did not help me much.

A small problem

VSCode v1.30.2
Windows7 64bit
When I compile a C++ file for the first time, if there are any compile errors, the extension will close the editor. I think there must be something wrong in the extension. Can you help me?

create .exe no longer compiles

When I press f6 to run the project, only the .exe file is created, but it does not start in the visual code terminal, but in the external terminal it runs without problems, but I wanted to use the own visual code terminal. The problem is that the command to start .exe is like this, for example, "index.exe" and not. \ Index.exe.

Captura de Tela (51)

as you can see in the image, only what is in "" is returned.

Note: I've seen other bug topics with the same bug, so far no solution of the same

Version VSCODE : 1.37.1
OS: Windows_NT x64 10.0.18362

Add the ability to specify additional include paths

Is your feature request related to a problem? Please describe.
My most common use of a Compile & Run plug-in is too run small .cpp files in projects that are just small tools - so not handled by my CMake configuration because not "part of the project" enough - but which might include header files from my projects.

Describe the solution you'd like
I would like the ability to specify a list of additional directories to add to the include paths from the configuration file.

Describe alternatives you've considered
An even more convenient solution could be to take into account the includePath field of the c_cpp_properties.json generated by the official C/C++ VSCode plug-in when it exists. That would make my global project configuration even more consistent.

Additional context
I mostly develop header-only libraries, so I don't need a full build of other .cpp files, just the ability to specify more include paths. It is sufficient for my use case.

I can't use the key"F6"

Issue Type: Bug

I can't use the key"F6"

I have already had everything down,but it's still useless.

my c_cpp_properties.json is

{
    "configurations": [
        {
            "name": "Win64",
            "intelliSenseMode": "clang-x64",
            "compilerPath": "C:/Mingw/bin/g++.exe",
            "includePath": [
                "C:/MingW/lib/gcc/mingw32/6.3.0/include/c++/*",
                "C:/MingW/include/*",
                "C:/MingW/lib/gcc/mingw32/6.3.0/include/*",
                "C:/MingW/lib/gcc/mingw32/6.3.0/include/c++/*",
                "C:/MingW/lib/gcc/mingw32/6.3.0/include/c++/backward/*",
                "C:/MinGW/lib/gcc/mingw32/6.3.0/include/c++/tr1",
                "C:/MinGW/lib/gcc/mingw32/6.3.0/include/c++/ext/pb_ds",
                "C:/MinGW/lib/gcc/mingw32/6.3.0/include/c++/mingw32/bits"
            ],
            "defines": [],
            "browse": {
                "path": [
                    "${workspaceFolder}"
                ],
                "limitSymbolsToIncludedHeaders": true,
                "databaseFilename": ""
            },
            "cStandard": "c11",
            "cppStandard": "c++17",
            "clang.executable": "clang",
            "clang.completion.enable": true,
            "clang.cxxflags": [
                "-std=c++11",
                "C://Mingw//lib//gcc//mingw32//6.3.0//include//c++"
            ]
        }
    ],
    "version": 4
}

Extension version: 0.4.3
VS Code version: Code 1.30.2 (61122f88f0bf01e2ac16bdb9e1bc4571755f5bd8, 2019-01-07T22:54:13.295Z)
OS version: Windows_NT x64 10.0.17134

System Info
Item Value
CPUs Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz (8 x 1992)
GPU Status 2d_canvas: enabled
checker_imaging: disabled_off
flash_3d: enabled
flash_stage3d: enabled
flash_stage3d_baseline: enabled
gpu_compositing: enabled
multiple_raster_threads: enabled_on
native_gpu_memory_buffers: disabled_software
rasterization: enabled
video_decode: enabled
video_encode: enabled
webgl: enabled
webgl2: enabled
Memory (System) 7.89GB (3.47GB free)
Process Argv
Screen Reader no
VM 0%

New Keybinding for run in external(or vice versa of setting) Terminal

Most of the time, vscode integrated terminal works just fine.

But sometimes it is better to use external terminal for convenience.

Currently, only way(I can find of) to switch between integrated & external terminal is by changing setting of vscode.

C-cpp-compile-run: Run-in-external-terminal
Run in a new external terminal

Suggestion:
Add keybinding that allows to run in external(or vice versa of setting) terminal.

Thank you!

Bug when having trailing spaces in compiler flags

Describe the bug
If there are one or more trailing space-characters in the flags configuration, you get an error when trying to compile and run with F6

To Reproduce
Steps to reproduce the behavior:

  1. Go to Settings
  2. Add just one space to the C-flags (i did not test with Cpp-flags)
  3. try to compile a c-file with F6
  4. you get: gcc: error: : No such file or directory
  5. remove trailing space from flag settings, everything works fine again.

Environment

  • VSCode Version: [e.g. 1.29]
  • OS Version: Windows 10 x64

Additional context
I am not good at Javascript, but my guess is that the trim() function could help here

Breakpoints missing

Is your feature request related to a problem? Please describe.

  • Problem is wrong compiling string in \out\CompileRun.js that leads to missing breakpoints for debugging in output file.

Describe the solution you'd like
need add simple '-g' in compile string

line 33
let exec; let compilerArgs = ['-g', file.$name, '-o', file.$executable]; let compilerSetting; let compilerSettingKey;

Describe alternatives you've considered
Hardest way is to implement additional parameter "compiler string" - to be able add anything else ... or read included in project file tasks,json for "args" string but here we have another dificulty when tasks >1 :-)

Auto save file

How about adding the feature that automatically saving file before compilation?

How can i compile and run my c programming file in visual studio code?

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Environment

  • VSCode Version: [e.g. 1.28.2]
  • OS Version: [e.g. Windows_NT x64 10.0.17134]

Additional context
Add any other context about the problem here.

'. ' is not an internal or external command, nor a runnable program.

Describe the bug
When and use this extensions in my program , after compile , when it tried to run this program , it shows : '. ' is not an internal or external command, nor a runnable program.
In terminal , the command is ' cmd /c ./xxxx.exe'

Environment

  • VSCode Version: 1.28.2
  • OS Version: Windows10 1803
  • GCC: MINGW32-W64 8.1.0

A run command with parameters

Change the format of setting, just like the JS template string lets the user set the command with variables.

"c-cpp-compile-run.run-command" = "gnome-terminal -e 'sh -c "${outputFile}; read -n1 -p "Press any key to continue...""'"
Then we getSetting<string>(key.runCommand).replace("${outputFile}", outputFile) and run again.

Originally posted by @Anti-Li in #28 (comment)

"Run" not working automatically

When I press F6, compile, but not Run. Because the command for Run is:
.\main.exe
But the extension puts:
"main.exe"

How I can edit the prefix for run?

Compiles but doesn't run

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. Open the file in VS Code
  2. Do "Compile & Run"
  3. The program is compiled (VS Code also says it in the bottom-right corner), but the terminal gives an error. Compile & run gives the command "cmd /c ./FileName.exe", but the terminal says that "." isn't a recognized command.

Expected behavior
The terminal should have executed the file. Probably the problem is in the command given to execute.

Screenshots
image
(Sorry for the italian language)

Environment

  • VSCode Version: 1.28.2
  • OS Version: Windows 10 x64 1809

Additional context
It didn't happen before the latest update.

(Suggestion) Warning when compiling while running

Is your feature request related to a problem? Please describe.
When you try to compile while the program is running gives the error "collect2.exe: error: ld returned 1 exit status". This is related to GCC of course. However, this sometimes happens because you forgot to close the terminal that was running the program, and seeing this error might let you wonder what is this.

Describe the solution you'd like
If you try to compile while the program is running, the extension will warn you that you have to close the terminal. Maybe in the notification area in the bottom right area it could ask you if you prefer to close the terminal automatically or to abort the compilation, and in the extension configuration add the option to choose if you always want to choose or to always do one of the two.

Uses old C++ compiler even thought it was set for C++17. I am getting "non-aggregate type" error message.

  • Extension Name: c-cpp-compile-run
  • Extension Version: 0.4.3
  • OS Version: Darwin x64 17.7.0
  • VSCode version: 1.29.1

We have written the needed data into your clipboard. Please paste:

Getting the following error message wit VS Code. #Something is buggy in the extension.

I would expect the extension to add std=c++11 or std=c++17 parameter, but it doesn't add it even though it is configured.

g++ test.cpp -o test && >"/Users/ismail/Desktop/test/test.cpp
test.cpp: error: non-aggregate type 'std::vector' cannot be initialized with an initializer list
std::vector v = {1, 2, 3, 4};
^ ~~~~~~~~~~~~
1 error generated.

The compiler path doesn't work.

When I set a compiler path like "C:\MinGW\bin\g++.exe" but not like "g++.exe", it will tell me "Compiler not found, try to change path in settings!".
However, setting compiler path "g++" and adding "C:\MinGW\bin" into PATH resolve the problem.
Is there some problem with npm module command-exists?

How to change compiler options?

How to change compiler options in new version? ./out/extension.js has been changed so I couldn't find a way to edit compiler options such as-DLOCAL

no response with F6

vscode Version: 1.26.1
os: win10

no response with F6, I have a single hellowworld.cpp file, and have MinGW in window path, dose this plug-in need to config?

a smal bug in runing code

when I press f6 code compiles successfully but it doesn't run

as you can see it must be .\test.exe but it is "test.exe" and it can't run

Screenshot (229)

  • VSCode Version: 1.35.0
  • OS Version: Windows_NT x64 10.0.17134

Windows error

Describe the bug
Configure Mingwin path, addon likes path incorrect path no cmd window even opens. However, executing "compile" flashes so quickly I had to video capture it then screenshot it to show you that it appears to both be truncating the command it is trying to execute, but also probably attempting to incorrectly run bash and not cmd?

C:\Temp\notepad.c is already open successfully in vscode and if I drop to cmd I can compile myself.

To Reproduce
Steps to reproduce the behavior:

  1. Compile command

Expected behavior
Compile or at least run compiler.

Screenshots

snag_11-4-2018_05-28-17

Environment

  • VSCode Version: current stable 1.28.2
  • OS Version: Win7x64

Cannot run on windows when using Powershell

Describe the bug
For example, I'm just trying to compile and run HelloWorld.cpp
Powershell just cannot execute "HelloWorld.exe" but directly print it out as a string
The command should be ./"HelloWorld.exe"

To Reproduce
Steps to reproduce the behavior:

  1. Confirm that current Windows shell is Powershell
  2. Open the file in VS Code
  3. Do "Compile & Run"
  4. Your terminal prints out the name of the execuatble file
  5. Open Powershell, cd to the file's dictionary, enter the file name with quotation marks. Powershell prints it out.
  6. Enter the file name without quotation marks. Powershell warns that the command not found but the file did exist, and hints that you can add a '.' ('./' works too) before the file name to exec.
  7. add './' before (the file name with quotation masks) and try to exec again. It works.

Solution
Use the same execute command as on Linux or macOS when using Powershell

Environment

  • VSCode Version: 1.28.2
  • OS Version: Windows_NT x64 10.0.17134
  • Powershell Version: 5.1.17134.407
  • Extension Version: 0.4.3

Warning will be fleeting

Describe the bug
Warning will be passed.

To Reproduce
Compile.
Warning will be fleeting.

Expected behavior
I want to check it out.

Cannot Add Compiler Flags to Settings

The available settings are not showing the option for compiler flags:

image

Even when manually editing the user settings:

image

VS Code seems to be pulling a previous/older definition for the settings.

Environment:

  • Linux:Ubuntu 14.04
  • VS Code 1.28.1
  • C/C++ Compile Run 0.2.7

Extension not working

When pressing the key "F6" to compile the file 'hello.c', my console displays the following command:

gcc -Wall -Wextra 'd:\workspace\C\hello-world\hello.c' -o 'd:\workspace\C\hello-world\hello'

gcc: error: 'd:\workspace\C\hello-world\hello.c': Invalid argument
gcc: fatal error: no input files
compilation terminated.

causing an error; instead of the single quote marks ( ' ) to deliminate the paths, the double quotes ( " ) should be used instead.

Customizable Execuable Filename

First of all, I totally appreciate your hard work and it's an awesome extension.
I am a full-time C++ Developer and I feel that it would be great if you could add a settings that would allow to change the executable filename than the default which is present in line 70 of /src/CompileRun.ts

Debug support.

Feature:
When I click "debug" button, it will compile my program and run. Like what it do when I press F6.
Need single file debug api.

Output execute time

I am an algorithmic contestant. The execute time of the program is very important to me, so I want to know the execute time of the program when the program is finished.

When the setting cppFlags or cFlags is empty, g++ will tell me "No such file or directory".

Describe the bug
When the setting cppFlags or cFlags is empty, g++ will tell me "No such file or directory".

To Reproduce
Steps to reproduce the behavior:

  1. Delete the setting "cppFlags".
  2. Compile
  3. It tells me "No such file or directory", but I'm sure there is and when I add some flags it will be compiled.

Expected behavior
When cppFlags is empty, the command is like "g++ test.cpp -o test.exe", it won't tell me no such file forever and will compile normally.

Screenshots
image

Environment

  • VSCode Version: 1.29.1 (user setup)
  • OS Version: Windows_NT x64 10.0.17134

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.