Closed Smiril closed 1 year ago
Reference issue #5
I don't think that's what the problem was. I'll explain it in more in detail.
I had this line in the makefile:
@time -f $(TIME_FORMAT) -- $(COMPILE) $< -c -o $@
In zsh, time
is a command that takes no arguments and runs the rest of the line as if it were a program. So zsh started its time function and then tried to run -f $(TIME_FORMAT) -- $(COMPILE) $< -c -o $@
in the shell (which is located at /bin/sh
). The shell then reported that -f
is not a command. The ...
is something I printed to stdout using @printf "Building $@ ..."
in the makefile, therefore it is not part of the error.
If you are still encountering the error, maybe you need to pull from the master branch? Let me know how it goes and if you still need any help.
hello and thank you for your tipp
@time -al $(TIME_FORMAT) -- $(COMPILE) $< -c -o $@
this I can use
output from compiler:
clang: warning: treating 'c-header' input as 'c++-header' when in C++ mode, this behavior is deprecated [-Wdeprecated]
clang: warning: treating 'c-header' input as 'c++-header' when in C++ mode, this behavior is deprecated [-Wdeprecated]
clang: warning: treating 'c-header' input as 'c++-header' when in C++ mode, this behavior is deprecated [-Wdeprecated]
clang: warning: treating 'c-header' input as 'c++-header' when in C++ mode, this behavior is deprecated [-Wdeprecated]
Building build/bruteforce.o ...In file included from source/bruteforce.cpp:1:
In file included from source/bruteforce.h:11:
In file included from source/enigma.h:10:
In file included from source/datatypes.h:13:
source/util.h:23:6: error: no member named 'transform' in namespace 'std::ranges'; did you mean 'std::transform'?
std::ranges::transform(in, out.begin(), [] (char c) { return to_upper(c) - 'A'; });
^~~~~~~~~~~~~~~~~~~~~~
std::transform
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__algorithm/transform.h:26:1: note: 'std::transform' declared here
transform(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _UnaryOperation __op)
^
In file included from source/bruteforce.cpp:1:
In file included from source/bruteforce.h:11:
In file included from source/enigma.h:10:
In file included from source/datatypes.h:13:
source/util.h:52:31: error: no member named 'views' in namespace 'std'
for (char c : str | std::views::transform(to_ordinal))
~~~~~^
In file included from source/bruteforce.cpp:1:
In file included from source/bruteforce.h:11:
In file included from source/enigma.h:10:
source/datatypes.h:126:24: error: no member named 'transform' in namespace 'std::ranges'
std::ranges::transform(permutation, forward.begin(), [] (char c) { return c - 'A' + 26; } );
~~~~~~~~~~~~~^
source/datatypes.h:149:42: error: no member named 'views' in namespace 'std'
for (char c : turnovers | std::views::transform(to_upper)) turnover_value |= (1 << (c - 'A'));
~~~~~^
source/datatypes.h:210:6: error: defaulted definition of copy assignment operator is not constexpr
constexpr EnigmaKey& operator= (const EnigmaKey&) = default;
^
source/datatypes.h:271:6: error: defaulted definition of copy assignment operator is not constexpr
constexpr Enigma4Key& operator= (const Enigma4Key&) = default;
^
In file included from source/bruteforce.cpp:1:
In file included from source/bruteforce.h:11:
source/enigma.h:188:29: error: no type named 'input_range' in namespace 'std::ranges'
template <std::ranges::input_range R, std::weakly_incrementable O>
~~~~~~~~~~~~~^
source/enigma.h:189:46: error: no member named 'range_value_t' in namespace 'std::ranges'
requires std::same_as<std::ranges::range_value_t<R>, int> && std::same_as<std::iter_value_t<O>, int>
~~~~~~~~~~~~~^
source/enigma.h:258:29: error: no type named 'input_range' in namespace 'std::ranges'
template <std::ranges::input_range R, std::weakly_incrementable O>
~~~~~~~~~~~~~^
source/enigma.h:259:46: error: no member named 'range_value_t' in namespace 'std::ranges'
requires std::same_as<std::ranges::range_value_t<R>, int> && std::same_as<std::iter_value_t<O>, int>
~~~~~~~~~~~~~^
In file included from source/bruteforce.cpp:1:
In file included from source/bruteforce.h:13:
source/score.h:12:24: error: no type named 'random_access_range' in namespace 'std::ranges'
template <std::ranges::random_access_range R>
~~~~~~~~~~~~~^
source/score.h:13:41: error: no member named 'range_value_t' in namespace 'std::ranges'
requires std::same_as<std::ranges::range_value_t<R>, int> && std::ranges::sized_range<R>
~~~~~~~~~~~~~^
In file included from source/bruteforce.cpp:1:
source/bruteforce.h:24:42: error: no type named 'input_range' in namespace 'std::ranges'
template <class EnigmaType, std::ranges::input_range R1,
~~~~~~~~~~~~~^
source/bruteforce.h:25:24: error: no type named 'forward_range' in namespace 'std::ranges'
std::ranges::forward_range R2, class LeaderboardType,
~~~~~~~~~~~~~^
source/bruteforce.h:28:32: error: unknown type name 'R1'
EnigmaType& enigma, const R1& ct_ordinals, R2& pt_ordinals, LeaderboardType& scores, F scoring_function
^
source/bruteforce.h:28:49: error: unknown type name 'R2'
EnigmaType& enigma, const R1& ct_ordinals, R2& pt_ordinals, LeaderboardType& scores, F scoring_function
^
source/bruteforce.h:43:24: error: no type named 'forward_range' in namespace 'std::ranges'
template <std::ranges::forward_range R, int N = 10, class F = decltype(score_by_Qgram<std::vector<int>>)>
~~~~~~~~~~~~~^
source/bruteforce.h:43:72: error: use of undeclared identifier 'score_by_Qgram'
template <std::ranges::forward_range R, int N = 10, class F = decltype(score_by_Qgram<std::vector<int>>)>
^
source/bruteforce.h:45:82: error: unknown type name 'R'
const basic_enigma_base<EnigmaKey>& base, const Plugboard& plugboard, const R& ct_ordinals,
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
0,42 real 0,25 user 0,03 sys
77398016 maximum resident set size
0 average shared memory size
0 average unshared data size
0 average unshared stack size
7312 page reclaims
2 page faults
0 swaps
0 block input operations
0 block output operations
0 messages sent
0 messages received
0 signals received
1 voluntary context switches
592 involuntary context switches
99683685 instructions retired
38147776 cycles elapsed
7095232 peak memory footprint
make: *** [build/bruteforce.o] Error 1
when I add to makefile
TIME = /usr/bin/time
TIME_FORMAT = " %e seconds elapsed"
this will output 👍
clang: warning: treating 'c-header' input as 'c++-header' when in C++ mode, this behavior is deprecated [-Wdeprecated]
clang: warning: treating 'c-header' input as 'c++-header' when in C++ mode, this behavior is deprecated [-Wdeprecated]
clang: warning: treating 'c-header' input as 'c++-header' when in C++ mode, this behavior is deprecated [-Wdeprecated]
clang: warning: treating 'c-header' input as 'c++-header' when in C++ mode, this behavior is deprecated [-Wdeprecated]
Building build/bruteforce.o .../bin/sh: -al: command not found
real 0m0.005s
user 0m0.000s
sys 0m0.001s
make: *** [build/bruteforce.o] Error 127
after adding:
@/user/bin/time -al $(TIME_FORMAT) -- $(COMPILE) $< -c -o $@
this will happen
clang: warning: treating 'c-header' input as 'c++-header' when in C++ mode, this behavior is deprecated [-Wdeprecated]
clang: warning: treating 'c-header' input as 'c++-header' when in C++ mode, this behavior is deprecated [-Wdeprecated]
clang: warning: treating 'c-header' input as 'c++-header' when in C++ mode, this behavior is deprecated [-Wdeprecated]
clang: warning: treating 'c-header' input as 'c++-header' when in C++ mode, this behavior is deprecated [-Wdeprecated]
Building build/bruteforce.o ...time: %e seconds elapsed: No such file or directory
0,00 real 0,00 user 0,00 sys
917504 maximum resident set size
0 average shared memory size
0 average unshared data size
0 average unshared stack size
65 page reclaims
0 page faults
0 swaps
0 block input operations
0 block output operations
0 messages sent
0 messages received
0 signals received
0 voluntary context switches
1 involuntary context switches
1877143 instructions retired
1359186 cycles elapsed
819840 peak memory footprint
make: *** [build/bruteforce.o] Error 127
change it to :::
$(MAIN): $(MAIN).cpp $(OBJS)
@printf "Building $@ ..."
#define __linux__
@$(TIME) -f $(TIME_FORMAT) -- $(COMPILE) $< -c -o $@
#else
@/usr/bin/time -al $(TIME_FORMAT) -- $(COMPILE) $< -c -o $@
#endif
.PHONY: debug
debug:
@$(BASE_COMPILE) -ggdb -Og $(MAIN).cpp $(SRCS) -o $(MAIN)
.PHONY: $(MAIN)_callgrind
$(MAIN)_callgrind:
@echo "Building $@ ..."
#define __linux__
@$(TIME) -f $(TIME_FORMAT) -- $(COMPILE) -ggdb $(MAIN).cpp $(SRCS) -o $(MAIN)
#else
@/usr/bin/time -al $(TIME_FORMAT) -- $(COMPILE) -ggdb $(MAIN).cpp $(SRCS) -o $(MAIN)
#endif
valgrind --tool=callgrind --simulate-cache=yes ./$(MAIN)
build/%.o: source/%.cpp source/%.h
@mkdir -p build
@printf "Building $@ ..."
#define __linux__
@$(TIME) -f $(TIME_FORMAT) -- $(COMPILE) $< -c -o $@
#else
@/usr/bin/time -al $(TIME_FORMAT) -- $(COMPILE) $< -c -o $@
#endif
# ======================================================================================================================
# Tests
# ======================================================================================================================
TEST_SRCS = $(filter-out tests/main.test.cpp,$(shell find tests/ -name "*.test.cpp"))
TEST_EXES = $(addprefix build/,$(TEST_SRCS:.cpp=.out))
tests: build/tests/main.test.o $(TEST_EXES)
# Recompiles a single file on change, so the test harness can autorun. Pass relative src= on the command line.
.PHONY: watch-test
watch-test: exe=build/$(basename $(src)).out
watch-test:
@if [ -f "$(src)" ]; then \
while true; do \
clear; \
$(MAKE) $(exe) --no-print-directory; \
\
echo "watching $(notdir $(src)) ..."; \
inotifywait -qq -e modify $(src); \
done; \
else \
echo "file doesn't exist: $(src)"; \
fi
build/tests/%.test.out: tests/%.test.cpp $(OBJS)
@printf "Building $(@F) ..."
@mkdir -p $(@D)
#define __linux__
@$(TIME) -f $(TIME_FORMAT) -- $(COMPILE) -ggdb build/tests/main.test.o $(OBJS) $< -o $@
#else
@/usr/bin/time -al $(TIME_FORMAT) -- $(COMPILE) -ggdb build/tests/main.test.o $(OBJS) $< -o $@
#endif
build/tests/main.test.o: tests/main.test.cpp
@printf "Building $(@F) ..."
@mkdir -p $(@D)
#define __linux__
@$(TIME) -f $(TIME_FORMAT) -- $(COMPILE) $< -c -o $@
#else
@/usr/bin/time -al $(TIME_FORMAT) -- $(COMPILE) $< -c -o $@
#endif
There are still bugs in your code. Your time
command output is also different than mine. I'm not sure what you are trying to do here, so here is what I can think of to help.
time
command and already have it working for you, continue to use that in your own fork.time
command to work on your system using the same format as I use, you can continue this discussion with me and we will work out the bugs.time
command and just want to use the code, you can change this @$(TIME) --format=$(TIME_FORMAT) -- $(COMPILE) $(MAIN).cpp $(OBJS) -o $@
to this $(COMPILE) $(MAIN).cpp $(OBJS) -o $@
everywhere in the makefile (in your own fork).
hello ... the fork from /bin/sh -f
is simply in dir this by . is simply in dir parent by .. and then fork /bin/sh
this means .../bin/sh -f
had a dir /Users/USERNAME/github/bruteforce-enigma in linux /home/USERNAME/github/bruteforce-enigma
in folder GitHub is no folder bin with binary sh