From 98dfdfc2aaa92bacdc94fedc433931cb3ea66a0a Mon Sep 17 00:00:00 2001 From: Sebastiano Tronto Date: Sat, 4 May 2024 18:36:31 +0200 Subject: Added .gitignore; C++ example clean up; example compile script clean up --- .gitignore | 3 +++ cube.o | Bin 23088 -> 32688 bytes example/a.out | Bin 49752 -> 75960 bytes example/compile.sh | 7 ++++++- example/example.cpp | 10 +++++----- example/example.o | Bin 33856 -> 0 bytes 6 files changed, 14 insertions(+), 6 deletions(-) create mode 100644 .gitignore delete mode 100644 example/example.o diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..011690f --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +cube.o +example/a.out +example/example.o diff --git a/cube.o b/cube.o index e61cb30..0617e03 100644 Binary files a/cube.o and b/cube.o differ diff --git a/example/a.out b/example/a.out index ef2babe..59a9f1a 100755 Binary files a/example/a.out and b/example/a.out differ diff --git a/example/compile.sh b/example/compile.sh index 4ce3bd2..fe9f133 100755 --- a/example/compile.sh +++ b/example/compile.sh @@ -1 +1,6 @@ -g++ example.cpp ../cube.o +#!/bin/sh + +compiler="$((g++ -v 2>/dev/null && echo "g++") ||\ + (clang++ -v 2>/dev/null && echo "clang++"))" + +${compiler} -std=c++14 example.cpp ../cube.o diff --git a/example/example.cpp b/example/example.cpp index c7ec982..3fa7d66 100644 --- a/example/example.cpp +++ b/example/example.cpp @@ -6,18 +6,18 @@ extern "C" { #include "../cube.h" } -cube_t apply_alg(cube_t cube, std::vector *moves) { - auto ret = cube; +cube_t apply_alg(cube_t cube, std::vector& moves) { + auto ret {cube}; - for (auto m : *moves) + for (auto m : moves) ret = cube_move(ret, m); return ret; } int main() { - auto cube = cube_new(); - auto moves = new std::vector { R, U, R3, U3 }; + auto cube {cube_new()}; + std::vector moves { R, U, R3, U3 }; char cstr[500]; std::cout << "The solved cube looks like this in H48 notation:\n"; diff --git a/example/example.o b/example/example.o deleted file mode 100644 index af95a15..0000000 Binary files a/example/example.o and /dev/null differ -- cgit v1.3