{"id":31686422,"url":"https://github.com/m3y54m/c-dev-container","last_synced_at":"2026-05-14T23:13:14.574Z","repository":{"id":318221434,"uuid":"1069928082","full_name":"m3y54m/c-dev-container","owner":"m3y54m","description":"A minimal C project template with CMake build system and VSCode devcontainer.","archived":false,"fork":false,"pushed_at":"2025-10-05T20:57:49.000Z","size":24,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-10-05T22:28:51.689Z","etag":null,"topics":["c-programming","clang","devcontainer","docker","valgrind","vscode"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/m3y54m.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-10-04T22:38:21.000Z","updated_at":"2025-10-05T20:57:52.000Z","dependencies_parsed_at":"2025-10-05T22:28:56.706Z","dependency_job_id":null,"html_url":"https://github.com/m3y54m/c-dev-container","commit_stats":null,"previous_names":["m3y54m/c-dev-container"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/m3y54m/c-dev-container","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/m3y54m%2Fc-dev-container","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/m3y54m%2Fc-dev-container/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/m3y54m%2Fc-dev-container/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/m3y54m%2Fc-dev-container/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/m3y54m","download_url":"https://codeload.github.com/m3y54m/c-dev-container/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/m3y54m%2Fc-dev-container/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33046906,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-13T13:14:54.681Z","status":"online","status_checked_at":"2026-05-14T02:00:06.663Z","response_time":57,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c-programming","clang","devcontainer","docker","valgrind","vscode"],"created_at":"2025-10-08T09:26:22.019Z","updated_at":"2026-05-14T23:13:14.568Z","avatar_url":"https://github.com/m3y54m.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# C Project Template Using DevContainer\n\nA minimal C project template with CMake build system and VSCode devcontainer.\n\n## Features\n\n- Simple C program with standard directory structure\n- CMake build system configured for C17 standard\n- Clang compiler with clangd for enhanced IntelliSense\n- VSCode devcontainer with Docker\n- Essential C development tools pre-installed\n\n## Getting Started\n\n1. Open this project in VSCode\n2. When prompted, click \"Reopen in Container\" or use Command Palette: `Dev Containers: Reopen in Container`\n3. The container will automatically build the project\n4. Run the program: `./build/bin/hello_world`\n\n## Project Structure\n\n```\n.\n├── .devcontainer/\n│   ├── devcontainer.json   # VSCode devcontainer configuration\n│   ├── Dockerfile          # Docker image definition\n│   ├── GIT_SETUP.md        # Git setup documentation\n│   └── setup-git.sh        # Git configuration setup script\n├── src/\n│   └── main.c              # Main C source file\n├── build/                  # Build output directory\n│   └── debug/             # Debug build artifacts\n│       ├── bin/           # Debug executables\n│       └── ...            # CMake build files\n├── .clang-format           # Code formatting configuration\n├── .clang-tidy             # Static analysis configuration  \n├── .clangd                 # Language server configuration\n├── CMakeLists.txt          # CMake build configuration\n├── CMakePresets.json       # CMake preset configurations\n├── GITHUB_ACTIONS_GUIDE.md # GitHub Actions CI documentation\n├── VALGRIND_GUIDE.md       # Valgrind memory debugging guide\n├── .gitignore             # Git ignore rules\n└── README.md              # This file\n```\n\n## Building\n\n### Using CMake Presets (Recommended)\n\n#### Build and Run (One Command)\n```bash\n# Build debug and run immediately\ncmake --preset debug \u0026\u0026 cmake --build --preset run-debug\n\n# Build release and run immediately\ncmake --preset release \u0026\u0026 cmake --build --preset run-release\n```\n\n#### Build Only\n```bash\n# Debug build\ncmake --preset debug\ncmake --build --preset debug\n./build/debug/bin/hello_world\n\n# Release build\ncmake --preset release\ncmake --build --preset release\n./build/release/bin/hello_world\n```\n\n### Manual Building\n\n```bash\nmkdir build\ncd build\ncmake ..\nmake\n./bin/hello_world\n```\n\n## Code Quality Tools\n\nThe project includes comprehensive code quality configurations:\n\n### `.clang-format`\n- **LLVM-based style** with C-specific adjustments\n- **4-space indentation** with Linux brace style\n- **100-character line limit** for readability\n- **Automatic include sorting** and formatting\n\n### `.clang-tidy`\n- **C-focused static analysis** checks\n- **Bug detection** and performance analysis\n- **Code style enforcement** with snake_case naming\n- **Security checks** (CERT guidelines)\n\n### `.clangd`\n- **C17 standard** support with background indexing\n- **Inlay hints** for parameters and types\n- **Integration** with clang-format and clang-tidy\n\nThese tools provide:\n- Real-time code formatting and linting\n- Advanced code completion and navigation\n- Static analysis and bug detection\n- Consistent code style enforcement\n\n## Development Tools Included\n\n- **Clang compiler** (C17 standard) with maximum optimization for release builds\n- **Clangd language server** for enhanced IntelliSense and code analysis\n- **Clang-tidy** for static analysis and code quality checks\n- **CMake build system** with automatic configuration\n- **LLDB debugger** for debugging (integrated with clangd)\n- **Valgrind** memory checker for detecting leaks, buffer overflows, and memory errors\n- **Git** with SSH signing support\n- **Docker extension** for container management\n- **VSCode extensions**: clangd, CMake Tools, Docker, CodeLLDB, GitHub Actions\n\n## Build Configurations\n\n### Debug Build\n- **Optimization**: `-O0` (no optimization for easier debugging)\n- **Debug symbols**: `-g` (full debugging information)\n- **Warnings**: `-Wall -Wextra` (comprehensive warning detection)\n- **Size**: ~17KB (with debug symbols)\n\n### Release Build (Maximum Optimization)\n- **Optimization**: `-O3` (maximum speed optimization)\n- **Link-time optimization**: `-flto` (whole-program optimization)\n- **CPU-specific**: `-march=native -mtune=native` (optimized for current CPU)\n- **Math optimization**: `-ffast-math` (aggressive floating-point optimizations)\n- **Loop optimization**: `-funroll-loops` (unroll loops for speed)\n- **Frame pointer**: `-fomit-frame-pointer` (smaller, faster code)\n- **Dead code elimination**: `-Wl,--gc-sections` (remove unused code)\n- **Symbol stripping**: `-Wl,--strip-all` (remove debug symbols)\n- **Size**: ~15KB (highly optimized)\n\n## Debugging\n\nThe project is configured for debugging with LLDB (Low Level Debugger) which integrates seamlessly with clangd:\n\n### VS Code Debugging\n1. **Set breakpoints** by clicking in the gutter next to line numbers\n2. **Press F5** or go to Run and Debug panel\n3. **Select debug configuration**:\n   - \"Debug with LLDB\" (debug build)\n\n### Debug Features\n- **Breakpoints** and step-through debugging\n- **Variable inspection** and watch expressions\n- **Call stack** navigation\n- **Integrated terminal** for LLDB commands\n- **Automatic build** before debugging\n\n### Command Line Debugging\n```bash\n# Build debug version\ncmake --preset debug \u0026\u0026 cmake --build --preset debug\n\n# Debug with LLDB\nlldb build/debug/bin/hello_world\n(lldb) breakpoint set --name main\n(lldb) run\n```\n\n## Memory Debugging with Valgrind\n\nValgrind is integrated for detecting memory leaks, buffer overflows, and other memory issues:\n\n### Command Line Usage\n```bash\n# Basic memory check\nvalgrind ./build/debug/bin/hello_world\n\n# Full memory check with leak detection\nvalgrind --leak-check=full --show-leak-kinds=all --track-origins=yes ./build/debug/bin/hello_world\n\n# Cache profiling\nvalgrind --tool=cachegrind ./build/debug/bin/hello_world\n```\n\n### VS Code Integration\n- **Press `Ctrl+Shift+P`** → \"Tasks: Run Task\" → \"valgrind-check\"\n- **Or use the terminal**: `valgrind --leak-check=full ./build/debug/bin/hello_world`\n\n### What Valgrind Detects\n- **Memory leaks** (allocated but never freed)\n- **Buffer overflows** (writing beyond allocated memory)\n- **Use after free** (accessing freed memory)\n- **Double free** (freeing the same memory twice)\n- **Uninitialized memory** access\n\nSee `VALGRIND_GUIDE.md` for comprehensive usage instructions.\n\n## Documentation\n\nThe project includes comprehensive documentation for various development workflows:\n\n### 📚 **Available Guides**\n\n#### **`GITHUB_ACTIONS_GUIDE.md`**\n- **CI/CD workflow** setup and configuration\n- **GitHub Actions** integration and automation\n- **Build pipeline** management and troubleshooting\n- **Artifact handling** and deployment strategies\n\n#### **`VALGRIND_GUIDE.md`**\n- **Memory debugging** with Valgrind Memcheck\n- **Performance profiling** with Cachegrind\n- **Memory leak detection** and analysis\n- **Advanced Valgrind** usage patterns and tips\n\n#### **`.devcontainer/GIT_SETUP.md`**\n- **Git configuration** setup in dev containers\n- **SSH key management** and commit signing\n- **Troubleshooting** common Git issues\n- **Security best practices** for development\n\n### 📖 **Quick Reference**\n\n| Guide | Purpose | When to Use |\n|-------|---------|-------------|\n| `GITHUB_ACTIONS_GUIDE.md` | CI/CD workflows | Setting up automated builds and testing |\n| `VALGRIND_GUIDE.md` | Memory debugging | Finding memory leaks and performance issues |\n| `GIT_SETUP.md` | Git configuration | Troubleshooting Git setup in containers |\n\n## Static Analysis with clang-tidy\n\nThe project includes a comprehensive clang-tidy configuration (`.clang-tidy`) with 200+ checks:\n\n### Check Categories Enabled\n\n#### 🐛 **Bug Detection (`bugprone-*`):**\n- **Buffer overflows** and null pointer dereferences\n- **Memory leaks** and use-after-free detection\n- **Infinite loops** and suspicious conditions\n- **Macro issues** and string handling problems\n- **Narrowing conversions** and type safety\n\n#### 🚀 **Performance (`performance-*`):**\n- **Inefficient loops** and unnecessary copies\n- **Move semantics** and copy optimization\n- **Type promotions** in math functions\n- **Automatic move** detection\n\n#### 📖 **Readability (`readability-*`):**\n- **Function complexity** (max 20 cognitive complexity)\n- **Function size** (max 50 lines)\n- **Identifier naming** (min 3 characters)\n- **Code formatting** and brace usage\n- **Magic numbers** detection\n\n#### 🔄 **Modernization (`modernize-*`):**\n- **Deprecated functions** detection\n- **Loop conversion** suggestions\n- **Auto keyword** usage\n- **Nullptr** instead of NULL\n- **Override** keyword usage\n\n#### 🛡️ **Security (`cert-*`):**\n- **Buffer overflow** prevention\n- **Integer overflow** detection\n- **Unsafe functions** warnings\n- **Memory management** issues\n\n### Usage\n\n#### **Command Line:**\n```bash\n# Basic analysis\nclang-tidy src/main.c -- -Ibuild/debug -std=c17\n\n# With specific checks\nclang-tidy -checks='bugprone-*,performance-*' src/main.c -- -Ibuild/debug -std=c17\n```\n\n#### **VS Code Integration:**\n- **Real-time analysis** with clangd extension\n- **Error highlighting** in editor\n- **Quick fixes** for common issues\n- **Hover information** for warnings\n\n#### **CI Integration:**\n- **Automated analysis** on every commit\n- **Error reporting** in pull requests\n- **Artifact upload** for detailed reports\n\n### Configuration\n\nThe `.clang-tidy` file includes:\n- **200+ enabled checks** across all categories\n- **Custom thresholds** for complexity and size\n- **Naming conventions** for identifiers\n- **Performance warnings** configuration\n- **Excluded checks** for C++-specific rules\n\n### Example Output\n\n```\nsrc/main.c:30:9: warning: variable name 'i' is too short, expected at least 3 characters [readability-identifier-length]\nsrc/main.c:31:5: warning: kernel performance could be improved by unrolling this loop [altera-unroll-loops]\nsrc/main.c:39:19: warning: parameter name 'a' is too short [readability-identifier-length]\nsrc/main.c:41:19: warning: statement should be inside braces [readability-braces-around-statements]\nsrc/main.c:51:30: warning: narrowing conversion from 'unsigned long' to signed type 'int' [bugprone-narrowing-conversions]\n```\n\n## Continuous Integration\n\nThe project includes a comprehensive GitHub Actions CI workflow that runs on every push and pull request:\n\n### CI Pipeline Features\n\n#### ✅ **Multi-Build Testing:**\n- **Debug build** with full debugging symbols\n- **Release build** with maximum optimization\n- **Parallel builds** using all available CPU cores\n\n#### ✅ **Static Analysis:**\n- **clang-tidy** with comprehensive checks (200+ rules)\n- **Bug detection** (buffer overflows, null pointer derefs, etc.)\n- **Performance analysis** (inefficient loops, unnecessary copies)\n- **Code style** enforcement (naming, formatting, complexity)\n- **Modern C practices** (deprecated functions, best practices)\n- **C17 standard** compliance verification\n- **Warning detection** with `-Wall -Wextra`\n\n#### ✅ **Dynamic Analysis:**\n- **Valgrind Memcheck** for memory leak detection\n- **Valgrind Cachegrind** for performance profiling\n- **Both debug and release** builds tested\n\n#### ✅ **Artifact Management:**\n- **Build artifacts** uploaded for inspection\n- **Valgrind reports** preserved for analysis\n- **7-day retention** for debugging failed builds\n\n### CI Workflow Triggers\n- **Push** to `main` or `master` branch\n- **Pull requests** targeting `main` or `master` branch\n\n### Viewing CI Results\n\n#### **GitHub Actions Extension (VS Code):**\n- **Real-time workflow status** in the sidebar\n- **Pinned workflows** for quick access\n- **Log viewing** directly in VS Code\n- **Workflow management** and re-running\n- **Artifact download** from the editor\n\n#### **GitHub Web Interface:**\n1. Go to your GitHub repository\n2. Click on **\"Actions\"** tab\n3. Select the workflow run\n4. Download artifacts for detailed analysis\n\n### GitHub Actions Extension Features\n\nThe dev container includes the **GitHub Actions extension** with:\n\n#### ✅ **Workflow Management:**\n- **Pin workflows** for quick access\n- **View workflow status** in real-time\n- **Re-run failed workflows** with one click\n- **Cancel running workflows** when needed\n\n#### ✅ **Log Integration:**\n- **View logs** directly in VS Code\n- **Syntax highlighting** for YAML workflows\n- **Error highlighting** and navigation\n- **Step-by-step execution** tracking\n\n#### ✅ **Artifact Management:**\n- **Download artifacts** from VS Code\n- **Browse build outputs** without leaving the editor\n- **Valgrind reports** accessible locally\n- **Build artifacts** inspection\n\n#### ✅ **Development Workflow:**\n- **Edit workflows** with IntelliSense\n- **Validate YAML** syntax\n- **Quick actions** for common tasks\n- **Integration** with Git operations\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fm3y54m%2Fc-dev-container","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fm3y54m%2Fc-dev-container","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fm3y54m%2Fc-dev-container/lists"}