diff --git a/README.md b/README.md index 0007380..9bff5a1 100644 --- a/README.md +++ b/README.md @@ -21,4 +21,12 @@ Add to user environment variables ``` Lua51_ROOT = "C:\\windows\lua" +``` + + +## Build + +``` +cmake -DCMAKE_BUILD_TYPE=Release -S . -B build +cmake --build build --target all ``` \ No newline at end of file diff --git a/basics/constness/CMakeLists.txt b/basics/constness/CMakeLists.txt index 04e4154..1e2645a 100644 --- a/basics/constness/CMakeLists.txt +++ b/basics/constness/CMakeLists.txt @@ -1,2 +1,5 @@ add_executable(const-1 const-1.cpp) add_executable(const-2 const-2.cpp) +add_executable(const-3 const-3.cpp) +add_executable(const-4 const-4.cpp) +add_executable(const-5 const-5.cpp) diff --git a/basics/constness/const-1.cpp b/basics/constness/const-1.cpp index 85acd13..cf4e121 100644 --- a/basics/constness/const-1.cpp +++ b/basics/constness/const-1.cpp @@ -2,7 +2,7 @@ int main(int argc, char const *argv[]) { const char* const_variable = nullptr; const_variable = new char[5]; - const_variable[0] = 'H'; // error: expression must be a modifiable lvalue - delete const_variable; + // const_variable[0] = 'H'; // error: expression must be a modifiable lvalue + delete[] const_variable; return 0; } diff --git a/basics/constness/const-2.cpp b/basics/constness/const-2.cpp index 6757e65..0354748 100644 --- a/basics/constness/const-2.cpp +++ b/basics/constness/const-2.cpp @@ -1,8 +1,8 @@ int main(int argc, char const *argv[]) { char* const const_variable = nullptr; - const_variable = new char[5]; // error: expression must be a modifiable lvalue + // const_variable = new char[5]; // error: expression must be a modifiable lvalue const_variable[0] = 'H'; - delete const_variable; + delete[] const_variable; return 0; } diff --git a/basics/constness/const-3.cpp b/basics/constness/const-3.cpp index e97fef1..97aebc9 100644 --- a/basics/constness/const-3.cpp +++ b/basics/constness/const-3.cpp @@ -7,6 +7,6 @@ int main(int argc, char const *argv[]) const_variable[3] = 'l'; const_variable[4] = 'o'; delete const_variable; - const_variable = nullptr; // error: expression must be a modifiable lvalue + // cons[]t_variable = nullptr; // error: expression must be a modifiable lvalue return 0; } diff --git a/basics/constness/const-4.cpp b/basics/constness/const-4.cpp index 1bdadf4..8e9fd8f 100644 --- a/basics/constness/const-4.cpp +++ b/basics/constness/const-4.cpp @@ -1,8 +1,8 @@ int main(int argc, char const *argv[]) { const char* const const_variable = new char[5]; - const_variable[0] = 'H'; // error: expression must be a modifiable lvalue - delete const_variable; - const_variable = nullptr; // error: expression must be a modifiable lvalue + // const_variable[0] = 'H'; // error: expression must be a modifiable lvalue + delete[] const_variable; + // const_variable = nullptr; // error: expression must be a modifiable lvalue return 0; } diff --git a/oop/destructor/protected-destructor.cpp b/oop/destructor/protected-destructor.cpp index dfb9d07..8148d74 100644 --- a/oop/destructor/protected-destructor.cpp +++ b/oop/destructor/protected-destructor.cpp @@ -13,8 +13,8 @@ class ProtectedDestructor { int main(int argc, char const *argv[]) { - ProtectedDestructor* obj = new ProtectedDestructor(); + const ProtectedDestructor* obj = new ProtectedDestructor(); // delete dynamic_cast(obj); - delete obj; + // delete obj; // error: destructor is inaccessible return 0; } diff --git a/oop/non_copyable/CMakeLists.txt b/oop/non_copyable/CMakeLists.txt index a83fe24..549d36a 100644 --- a/oop/non_copyable/CMakeLists.txt +++ b/oop/non_copyable/CMakeLists.txt @@ -1,4 +1,3 @@ -# set(CMAKE_CXX_STANDARD 17) -add_executable(non-copyable non-copyable.cpp) +# add_executable(non-copyable non-copyable.cpp) add_executable(func-in-derived-class func-in-derived-class.cpp) add_executable(func-in-derived-2 func-in-derived-2.cpp) diff --git a/patterns/CMakeLists.txt b/patterns/CMakeLists.txt index bd7ee6a..8013cd1 100644 --- a/patterns/CMakeLists.txt +++ b/patterns/CMakeLists.txt @@ -1,2 +1,2 @@ add_subdirectory(factory) -add_subdirectory(fsm) \ No newline at end of file +# add_subdirectory(fsm) \ No newline at end of file diff --git a/rand/CMakeLists.txt b/rand/CMakeLists.txt index 8229d0f..bd1f072 100644 --- a/rand/CMakeLists.txt +++ b/rand/CMakeLists.txt @@ -2,5 +2,6 @@ set(CMAKE_CXX_STANDARD 20) add_executable(randomness_test randomness-test.c) configure_file(decoded-20240131051421.bin ${CMAKE_CURRENT_BINARY_DIR}/decoded-20240131051421.bin COPYONLY) +target_link_libraries(randomness_test m) add_executable(tony_rand lrand.c) \ No newline at end of file diff --git a/rand/randomness-test.c b/rand/randomness-test.c index 3dbbda5..e6c08ae 100644 --- a/rand/randomness-test.c +++ b/rand/randomness-test.c @@ -144,12 +144,14 @@ int main(int argc, char const *argv[]) fseek(f, 0, SEEK_END); int size = ftell(f); printf("found %d bytes in binary file\n", size); - if (size <= 0) + if (size <= 0) { + fclose(f); return -1; + } fseek(f, 0, SEEK_SET); - int8_t *values = malloc(size); + int8_t* values = (int8_t*)malloc(size); fread(values, sizeof(int8_t), size, f); fclose(f); diff --git a/serialization/save-number.cpp b/serialization/save-number.cpp index eb6221b..608256c 100644 --- a/serialization/save-number.cpp +++ b/serialization/save-number.cpp @@ -1,4 +1,5 @@ #include +#include #define MIN(a, b) ((a < b) ? a : b) diff --git a/serialization/write-number.cpp b/serialization/write-number.cpp index 0ccadf5..dd2151a 100644 --- a/serialization/write-number.cpp +++ b/serialization/write-number.cpp @@ -3,7 +3,8 @@ #include #include -static char mem[100] +static char mem[100]; + template void write_number(T v, uint8_t* b, size_t type_size) { @@ -19,7 +20,6 @@ void save_pulse_value_into_nvram(const std::string &file_name_prefix, int id, T size_t size = sizeof(T) + 1; uint8_t *data = static_cast(std::calloc(size, sizeof(uint8_t))); write_number(value, data, size); - write_file_async(file_name, size, (unsigned char *)data, true); free(data); } diff --git a/templates/CMakeLists.txt b/templates/CMakeLists.txt index 321c022..228335d 100644 --- a/templates/CMakeLists.txt +++ b/templates/CMakeLists.txt @@ -2,5 +2,5 @@ add_subdirectory(enable_if) add_subdirectory(variadic) set(CMAKE_CXX_STANDARD 20) -add_executable(why why.cpp) +# add_executable(why why.cpp) add_executable(good-enum good-enum.cpp) \ No newline at end of file diff --git a/templates/variadic/variadic-template.cpp b/templates/variadic/variadic-template.cpp index ddeaa55..3da25cf 100644 --- a/templates/variadic/variadic-template.cpp +++ b/templates/variadic/variadic-template.cpp @@ -23,12 +23,11 @@ void cool_function(Hint hint, Ts... args) { } case Hint::COOL_THREE: { - if constexpr () - auto print_cool_three = [](const char* string, size_t size) { - std::cout << string; - }; std::cout << "COOL THREE: "; - print_cool_three(args...); + // auto print_cool_three = [](const char* string, size_t size) { + // std::cout << string; + // }; + // print_cool_three(args...); std::cout << std::endl; break; }