Setup
- Visual Studio Code (VSCode) - IDE for Windows, Linux, Mac
- To work remotely, you can use the Remote - SSH extension to connect to any server that supports SSH connection
- Extensions are installed into the local environment - extensions need to be installed individually within each remote environment we might want to work in
- Terminal can be opened from VSCode
- Autosave can be used
Editor
- It has intellisense and stuff
The clang compiler
- Most major programming languages have a governing body, often referred to as the Standards Committee, which decides what is allowed/disallowed in a programming language
- New standards are approved every so often (e.g. C++20)
- Compiler developers release a new version to support the new standard when one is released
- Main compilers for C/C++ programs
- Microsoft Visual C/C++ Compiler
- bundled with Microsoft Visual Studio
- GNU Compiler Collection (gcc)
- most commonly used compiler used by students and in academia, may still be true
- Most Linux installations have gcc pre-installed
- is official compiler for GNU and Linux systems
- clang/LLVM
- clang compiler - frontend that understands syntax of supported languages, converts to Intermediate Representation (IR) supported by the LLVM Compiler Infrastucture project
- To compile from the command line (using clang, for example), use
clang <files>
- Never supply names of header files on command line to compiler
- Compiler compiles all given implementation files and produces an executable file if compilation is succesful
- With no output file name, compiler defaults to using
a.out
- We can use additional command linen arguments for a compiler:
- e.g.
clang -std=c99 -g -Wall main.c -o myprogram
-std=c99
- C 1999 Standard
-g
- tells compiler to generate source level debug info
-Wall
- diagnostic flag that can be read as Warn All
-o
- change output
-I
- path for header files - don’t provide actual path to a header file!
- For CS136L:
CFLAGS="-std=c99 -g -Wall -I/u2/cs136l/pub/common"
- set compiler flags to variable
Compiling via VSCode
- Configure build task for project
- Create
.vscode
directory in project root, configure tasks with tasks.json
and launch.json