On 24.05.2017 16:27 Osman Zakir wrote:
>
> I could've sworn I changed all instances of "std_lib_facilties.h" to
> "cust_std_lib_facilities.h" since the book says to use them myself only
> until Chapter 10. Well, I'm attacking that one to this post anyway.
> Look at it, please. It's just one header file and no .cpp files (since
> it's mostly templates). It only includes the needed standard headers,
> though, so there aren't any custom headers included in it.
<rant>
The question is: why are all these templates and advanced functions
necessary to teach a simple GUI approach? Does any reader of the book
(do you) know what's going on under the hood? I guess no. :-(
</rant>
Well, I could compile and link your sources successfully after some
tweaks, as I said before. The following line:
std::string::const_iterator p = find(s.begin(), s.end(), '.');
in Graph.cpp (~ line #301) would neither compile with g++ (Linux or
Windows/MinGW) nor with clang (the latter under Linux only).
Error message from clang for completeness:
Building CXX object CMakeFiles/stroustrup.dir/Graph.cpp.o
FAILED: /usr/bin/clang++ -I/home/albrecht/git/fltk-1.3/build/Debug
-I/home/albrecht/git/fltk-1.3 -g -std=gnu++14 -MMD -MT
CMakeFiles/stroustrup.dir/Graph.cpp.o -MF
CMakeFiles/stroustrup.dir/Graph.cpp.o.d -o
CMakeFiles/stroustrup.dir/Graph.cpp.o -c ../../Graph.cpp
../../Graph.cpp:301:35: error: no matching function for call to 'find'
std::string::const_iterator p = find(s.begin(),
s.end(), '.');
^~~~
/usr/bin/../lib/gcc/x86_64-linux-gnu/5.4.0/../../../../include/c++/5.4.0/bits/streambuf_iterator.h:369:5:
note: candidate template ignored: could not match 'istreambuf_iterator'
against '__normal_iterator'
find(istreambuf_iterator<_CharT> __first,
^
1 error generated.
Note: I had to use C++11 features, but I also tried C++14 (see command
line). The same statement compiles with VS 2015. I don't know which
compiler is "correct" for whatever that means...
That said, when I ran the program I saw a window with a "Next" button. I
didn't get an exception though, even if I clicked "Next", which closed
the window and exited.
I put a breakpoint on
void Box::draw_lines() const
in main.cpp to see if this was called, but it was never reached. This is
likely the cause why the program doesn't show anything, but I really
don't know why that is so. There's *way too much* code to check to find
out why draw_lines() is never called. I even tried to add
void Box::draw() {
draw_lines();
}
but nothing happened. I gave up.
For those interested to test: I added CMakeLists.txt and could
successfully generate:
- Unix Makefiles for Linux
- MSYS Makefiles for MinGW (Windows)
- VS 2015/64 solution for Visual Studio 2015 (Windows)
Others may try to help, but I'm out of the game. Sorry.
Instructions: save all files from Osman's two recent posts in one
directory, run `patch -p1 osman_dr-s.diff` with the attached patch file,
then
$ mkdir build
$ cd build
$ cmake[-gui] -G "<your generator>" ..
$ make, ninja, start VS2015/17 etc..