Category Archives: C++

Start an application with the debugger attached

You can automatically attach the Visual Studio Just-In-Time debugger when a process is started on Windows. The steps are simple:

  • Open the Registry Editor
  • navigate to HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Image File Execution Options
  • Select the application you want to debug:
    • Either it already exists as subkey, then use that one
    • Or, you have to create a new key in Image File Execution Options with the name of the application (e.g. chrome.exe)
  • Create a new string value with name debugger and name vsjitdebugger.exe

regedit_debugger

Online C++ compilers

There are multiple C++ compilers available on the net which can be used online. The advantage is that you can check your prototypes and share them easily.

 CompilerStandardSyntax highlightingShow program stdoutInteractive inputView Assembler output
http://cpp.sh/gcc 4.9.2, Boost 1.55 availableC++98
C++11
C++14
yesyespossibleno
http://coliru.stacked-crooked.com/gcc 4.6
gcc 4.7
gcc 4.8
gcc 4.9
gcc 5.1
clang-3.6
C++98
C++11
C++14
C++17
yesyesnono
https://gcc.godbolt.org/ARM gcc 4.5.3
ARM gcc 4.6.3
ARM gcc 4.8.2
ARM64 gcc 4.8
AVR gcc 4.5.3
PowerPC gcc 4.8
x86 clang 3.0
x86 clang 3.2
x86 clang 3.3
x86 clang 3.4.1
x86 clang 3.5.0
x86 clang 3.5.1
x86 clang 3.6 (rc2)
x86 clang 3.7 (experimental)
x86 gcc 4.4.7
x86 gcc 4.5.3
x86 gcc 4.6.4
x86 gcc 4.7.3
x86 gcc 4.8.1
x86 gcc 4.8.2
x86 gcc 4.9.0
x86 gcc 4.9.0 (w/concepts)
x86 gcc 4.9.0 (w/concepts)
x86 gcc 4.9.2
x86 gcc 5.1.0
x86 icc 13.0.1
yesnonoyes
http://webcompiler.cloudapp.net/Microsoft Visual Studio 2015
19.00.23008.0(x86)
http://ideone.com/gcc 4.9.2
gcc 4.9.2 (C++14)
http://melpon.org/wandbox

Remarks

Example command lines for the Coliru online compiler

g++-4.6 -std=c++98  -O2 -Wall -Wextra -pedantic -pthread -pedantic-errors main.cpp -lm  && ./a.out
g++-4.7 -std=c++98  -O2 -Wall -Wextra -pedantic -pthread -pedantic-errors main.cpp -lm  && ./a.out
g++-4.7 -std=c++11  -O2 -Wall -Wextra -pedantic -pthread -pedantic-errors main.cpp -lm  && ./a.out
g++-4.8 -std=c++98  -O2 -Wall -Wextra -pedantic -pthread -pedantic-errors main.cpp -lm  && ./a.out
g++-4.8 -std=c++11  -O2 -Wall -Wextra -pedantic -pthread -pedantic-errors main.cpp -lm  && ./a.out
g++-4.9 -std=c++98  -O2 -Wall -Wextra -pedantic -pthread -pedantic-errors main.cpp -lm  && ./a.out
g++-4.9 -std=c++11  -O2 -Wall -Wextra -pedantic -pthread -pedantic-errors main.cpp -lm  && ./a.out
g++-4.9 -std=c++14  -O2 -Wall -Wextra -pedantic -pthread -pedantic-errors main.cpp -lm  && ./a.out
g++-5.1 -std=c++98  -O2 -Wall -Wextra -pedantic -pthread -pedantic-errors main.cpp -lm  && ./a.out
g++-5.1 -std=c++11  -O2 -Wall -Wextra -pedantic -pthread -pedantic-errors main.cpp -lm  && ./a.out
g++-5.1 -std=c++14  -O2 -Wall -Wextra -pedantic -pthread -pedantic-errors main.cpp -lm  && ./a.out
g++-5.1 -std=c++1z  -O2 -Wall -Wextra -pedantic -pthread -pedantic-errors main.cpp -lm  && ./a.out
clang++ -std=c++98  -O2 -Wall -Wextra -pedantic -pthread -pedantic-errors main.cpp -lm  && ./a.out
clang++ -std=c++11 -stdlib=libc++  -O2 -Wall -Wextra -pedantic -pthread -pedantic-errors main.cpp -lm  -lsupc++  && ./a.out
clang++ -std=c++14 -stdlib=libc++  -O2 -Wall -Wextra -pedantic -pthread -pedantic-errors main.cpp -lm  -lsupc++  && ./a.out
clang++ -std=c++1z -stdlib=libc++  -O2 -Wall -Wextra -pedantic -pthread -pedantic-errors main.cpp -lm  -lsupc++  && ./a.out

Other languages

http://ideone.com/ supports a lot of other languages, too.