Simple GNU Make–based C project template with thread-safe components.
main.cimplements thread-safe logging initialization and queue demonstration- Thread-safe queue library (
libs/queue/) for message passing using pthreads - Simple logging library (
libs/log.c/) with multiple log levels and thread-safe mutex protection - Unity test framework (
libs/unity/) for unit testing template.c/template.hprovide scaffolding for new modulesMakefiledrives the build, keeping outputs underbuild/
- Run
maketo compile everything; producesbuild/demousinggccwith debug info make cleanremoves thebuild/directorymake showshows build variables (C_SOURCES, OBJECTS, CFLAGS, LDFLAGS)
After building, execute ./build/demo to see:
[INFO] Log system initialized with thread-safe mutex
[INFO] Hello log.c
Hello World!, 0
Makefile: configurable compiler flags, include paths, and build directorymain.c: application entry point with thread-safe logginglibs/queue/: thread-safe circular buffer implementationlibs/log.c/: simple logging library by rxilibs/unity/: Unity test framework for C unit testingtemplate.c/template.h: example module structure
- 本项目使用 GNU Make 构建,包含线程安全组件的 C 语言项目模板。
main.c实现线程安全日志初始化和队列演示- 线程安全队列库 (
libs/queue/) 使用 pthreads 进行消息传递 - 简单日志库 (
libs/log.c/) 支持多级日志输出和线程安全互斥锁保护 template.c/template.h提供新模块的模板结构- 所有编译输出都放在
build/目录下,由Makefile统一管理
- 执行
make生成build/demo,默认使用带调试信息的gcc make clean会清理build/目录make show显示构建变量
构建完成后运行 ./build/demo 查看输出。
Makefile:可配置的编译器标志、包含路径和输出目录main.c:程序入口与线程安全日志libs/queue/:线程安全队列实现libs/log.c/:日志库libs/unity/:Unity 单元测试框架template.c/template.h:预留的模块结构