diff --git a/c-template/.github/copilot-instructions.md b/c-template/.github/copilot-instructions.md new file mode 100644 index 0000000..c352196 --- /dev/null +++ b/c-template/.github/copilot-instructions.md @@ -0,0 +1,7 @@ +# Workspace Instructions + +- Keep the project compatible with C11 and CMake 3.16 or newer. +- Put public headers in `include/`, implementations in `src/`, and tests in `tests/`. +- Keep reusable functionality in libraries and link executables to those libraries. +- Register tests with CTest and avoid adding dependencies unless the project needs them. +- Verify changes with `cmake -S . -B build`, `cmake --build build`, and `ctest --test-dir build --output-on-failure`. \ No newline at end of file diff --git a/c-template/.gitignore b/c-template/.gitignore new file mode 100644 index 0000000..a52d603 --- /dev/null +++ b/c-template/.gitignore @@ -0,0 +1,2 @@ +/build/ +/cmake-build-*/ \ No newline at end of file diff --git a/c-template/CMakeLists.txt b/c-template/CMakeLists.txt new file mode 100644 index 0000000..48ec035 --- /dev/null +++ b/c-template/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.16) + +project(c_template VERSION 1.0.0 LANGUAGES C) + +include(CTest) + +# add_library(greeting src/greeting.c) +# target_include_directories(greeting PUBLIC include) +# target_compile_features(greeting PUBLIC c_std_11) + +add_executable(c_template src/main.c) +# target_link_libraries(c_template PRIVATE greeting) + diff --git a/c-template/README.md b/c-template/README.md new file mode 100644 index 0000000..98dd292 --- /dev/null +++ b/c-template/README.md @@ -0,0 +1,31 @@ +# Laba 6 + +Найти и удалить в заданной строке лишние пробелы между словами и +знаками препинания + +## Requirements + +- CMake 3.16 or newer +- A C compiler with C11 support + +## Configure and build + +```sh +cmake -S . -B build +cmake --build build +``` + +## Run + +```sh +./build/c_template +``` + +## Test + +```sh +ctest --test-dir build --output-on-failure +``` + +The `greeting` library is an example of how to separate reusable code into a +public header and implementation. Replace it with your project's own modules. \ No newline at end of file diff --git a/c-template/src/main.c b/c-template/src/main.c new file mode 100644 index 0000000..4520831 --- /dev/null +++ b/c-template/src/main.c @@ -0,0 +1,7 @@ +#include + +int main(void){ + printf("Hello world"); + return(0); +} + diff --git a/c-template/tests/test_greeting.c b/c-template/tests/test_greeting.c new file mode 100644 index 0000000..1627ea7 --- /dev/null +++ b/c-template/tests/test_greeting.c @@ -0,0 +1,10 @@ +#include +#include + +#include "greeting.h" + +int main(void) +{ + assert(strcmp(greeting_message(), "Hello, world!") == 0); + return 0; +} \ No newline at end of file