I am currently using vscode on mac.
when using pair on .cpp file, the error message comes;
error: a space is required between consecutive right angle
brackets (use '> >')
on doing g++ -std=c++17 -g filename.cpp, error never comes out. But using g++ filename.cpp however, can't use this templates.
I can't even try tuple so have trouble working on it.
my current c_cpp_properties.json is like this;
enter image description here
and my launch.json is like this:
enter image description here
and lastly my tasks.json is like this:
enter image description here
How can i use g++ filename.cpp without those warning?
Using two consecutive > to close out nested template declarations is not legal in C++98/03, but is legal in C++11 (and later).
Your command g++ filename.cpp is (presumably) defaulting to C++98, while when you try g++ -std=c++17 -g filename.cpp you are expressly indicating that you want to compile for C++17.
Click on the bottom right button that says C++ (File type is automatically detected by vscode otherwise you have to select Language Mode for the file) and select Configure 'C++' language-based settings... - it will open settings.json file
Change field "C_Cpp.default.cppStandard" to "c++17"
To compile on the command line I used the following command - note here I am using Apple clang version 12.0.0
clang some_file.cpp -std=c++11 -lstdc++
In my vscode editor I added no changes and do not need any spaces between consecutive '>'.
Related
Using -fsanitizer while compiling programs helps in finding location of memory leaks easily. But how to use this with vscode.
I only know that for compiling a program in vscode through terminal we need to type in g++ file_name.cpp -o executable_name.exe and for running .\program_name
Adding -fsanitizer to this command as an argument does not work for me. How to compile your program using fsanitizer on vscode?
Edit: I have been trying to use it as
g++ -std=c++17 -O2 -Wall -fsanitize=address
tempCodeRunnerFile.cpp -o tempcodeRunnerfile.exe
But this keeps giving me some kind of error:
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lasan: No such file or directory
collect2.exe: error: ld returned 1 exit status
This is unrelated to VSCode. The problem is your platform - MinGW traditionally has poor sanitizer support.
Your MSYS2 environment, MINGW64, only supports UBSAN (with stripped-down error reporting, compile with -fsanitize=undefined -fsanitize-undefined-trap-on-error).
There's also CLANG64 environment, which does have ASAN. Install its Clang (pacman -S mingw-w64-clang-x86_64-clang), and compile using clang++ located at C:\msys64\clang64\bin. If you're compiling from MSYS2 terminal, make sure you start the right one: launch it with clang64.exe, or the "MSYS2 Clang x64" shortcut (I don't remember the exact name).
Any help with swift language code completion on coderunner, would be much appreciated.
On the website https://coderunnerapp.com/ its claimed that it does support it, but not sure if I need to enable it explicitly or if I'm missing something.
Setup Active Directory
In Terminal run
xcrun swift --version
If you see the version information, you’re all set. If the command fails with xcrun: error: unable to find utility "swift", not a developer tool or in PATH, you need to set the active developer directory:
sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
Create a Swift Template in CodeRunner
Open Preferences and switch to the Languages tab. Create a new entry in the list and name it “Swift”.
In the “Run Command:” text field, enter this command:
xcrun swift -sdk $(xcrun --show-sdk-path --sdk macosx) -i $filename
The “Code Template:” field should contain the code you want to start with when you create a blank Swift file in CodeRunner.
In the “File Extension” field, enter swift.
I am trying to build a C project on Eclipse CDT with gcc.
First build worked fine, then I made a change to the source and second build appeared to try and link to a load of files I had not specified, then gets errors complaining it cannot find them. The gcc command it is running is:
gcc "-LC:\\SVN\\FloodAssessmentTool\\branches\\floatlite\\float\\python\\libs" -o float.exe "float\\python\\Lib\\site-packages\\markupsafe\\_speedups.o" "float\\.metadata\\.plugins\\org.eclipse.cdt.make.core\\specs.o" -lpython27
Whereas I am only expecting:
gcc "-LC:\\SVN\\FloodAssessmentTool\\branches\\floatlite\\float\\python\\libs" -o float.exe -lpython27
The only library I have specified to link against in the project settings is python27...
Whats happening?
I have a Beaglebone (Rev: A6) and i want to develop C/C++ program in windows 7 using Eclipse and then transfer executable in the board. But i'm having trouble setting up compiler/debugger/toolchain needed for Beaglebone. Searching the internet only gives me how to setup environment in Linux like installing 'arm-linux-gnueabi', setting up the paths to 'includes' etc. I need a step by step instruction to set up the environment in Eclipse in a windows machine. Can anyone help ?
I have tried these steps:
1. I have GNUARM installed on windows.
2. On eclipse IDE i open a C++ project with Corss GCC.
3. From project -> properties -> C/C++ build -> settings i add 'arm-elf-' to every cross compiler command.
4. From the GNUARM installation directory i add few path to '.../include/' in the 'C++ General -> paths and symbos'.
my 'build all' shows something as below:
10:32:20 **** Build of configuration Debug for project h ****
make all
Building file: ../src/hello.cpp
Invoking: Cross G++ Compiler
arm-elf-g++ -I"C:\GNUARM\include\c++\4.1.1" -I"C:\GNUARM\include\c++\4.1.1\arm-elf" - I"C:\GNUARM\include\c++\4.1.1\backward" -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP - MF"src/hello.d" -MT"src/hello.d" -o "src/hello.o" "../src/hello.cpp"
Finished building: ../src/hello.cpp
Building target: h
Invoking: Cross G++ Linker
arm-elf-g++ -L"C:\GNUARM\lib\gcc\arm-elf\4.1.1\include" -o "h" ./src/hello.o
Finished building target: h
10:32:23 Build Finished (took 2s.967ms)
It is simple 'Hello world' printing program. From the project explorer 'Debug->src->hello.o -[arm/le]' i copy it and when run on beaglebone with
chmod ugo+x hello.o
./hello.o
-sh: ./hello.o: cannot execute binary file
the above massage is printed. I don't know what i did wrong. Perhaps the ARM environment in eclipse is set up incorrectly.
Isn't hello.o the pre-linked object file (just the compiled content of hello.cpp)? It doesn't contain the startup code or any library functions. The linker adds those to produce the final output.
Don't you want to run the linker ouput file h (which should already be executable)?
i got my answer here. http://www.acmesystems.it/foxg20_eclipse_windows_c. CodeSourcery was the toolchain that i was looking for and this also explains how to setup the corss compiling environment.
I am trying to debug clang using eclipse. I have put a break point in clang/lib/lex/preprocessor.cpp at the preprocessor's constructor.
I have set a "test.c" file as an argument in the debug configurations.
Went to Run-> Debug As-> Local C/C++ Application.
It asked "Choose local application to debug". I chose "clang" and clicked OK.
It started building the code. build completed.
Stopped at main() in the debug window. (No source available for main())
After some step overs, it says "terminated: gdb Debugger (Exited. Exit code=255)"
I am not taken to the clang code (preprocessor code). can someone please tell me how to debug the clang code.? I want to see the code flow in clang. and how clang is constructing the AST.
Clang binary in fact contains two apps: driver and compiler frontend itself. The latter is executed via -cc1 cmdline option. So, just add -v to clang command line to see the actual sequence of tool invocation, grab the frontend cmdline (the one containing -cc1) and use this cmdline for debugging.
Had the same problem - you are missing the -g flag (enable debug info) when you are building your binaries.
When running the cmake run it with the CMAKE_BUILD_TYPE option:
cmake -G "Eclipse <CDT_Version> - Unix Makefiles" -D_ECLIPSE_VERSION=<eclipse_version> -DCMAKE_BUILD_TYPE=Debug <llvm_source_path>
example :
cmake -G "Eclipse CDT4 - Unix Makefiles" -D_ECLIPSE_VERSION=4.4 -DCMAKE_BUILD_TYPE=Debug ../llvm/
hope that this helps.