VS-Code based set up for writing c programs in a containerised environment.
Steps to Set-up
-
Go through System_Requirements.txt for hardware and software requirements.
-
Clone the repo.
-
Go to DevEnvironmentForC folder. cd DevEnvironmentForC
-
Open this folder in VS-Code
-
It will ask to reopen the folder in container. Click Reopen. Otherwise open VS-Code Command pallete (f1) and execute following command DevContainers : Open Folder in container.
-
The image is built, and the container is spun up.
-
Go to .devcontainer folder. cd .devcontainer
-
Execute post-create.sh script to install required VS-Code extensions.
chmod +x post-create.sh
./post-create.sh
-
Go to hello_world folder.
cd .. cd c_programs cd hello_world
-
Compile hello_world.c and execute.
gcc -g hello_world.c -o hello_world
./hello_world
Remember to use -g flag to compile program with debug symbols. -g flag is required for debugging.
-
Set break-point and debug.
-
The .vscode/launch.json file is configured to use debugger with this program only i.e. for hello_world. To use debugger for any other program, edit launch.json and set "program" property with the path of executable file that you wish to debug.
Repository Tree Structure
├── .devcontainer
├── .env
├── Dockerfile
├── devcontainer.json
├── docker-compose.yml
└── post-create.sh
├── .vscode
└── launch.json
├── README.md
├── System_Requirements.txt
├── c_programs
└── hello_world
│ └── hello_world.c
├── history
└── .zsh_history
└── output
├── Output1.png
└── Output2.png