From bc12d981d0b7ed76b15c62287246813c53e702fa Mon Sep 17 00:00:00 2001 From: "A.M. Rowsell" Date: Tue, 20 Jun 2023 17:55:09 -0400 Subject: [PATCH] Link Windows exe statically, change location of std::flush The Windows exe has to be linked statically, because Windows is stupid and doesn't have dynamic libraries like the stdc++ lib available. Maybe it's in some .dll somewhere, but I can't be bothered. Linux is just better. The change to the location of flush will make the output look more "spigot"-like, ie with large numbers of digits generated, the digits will be output in small groups instead of a nice smooth digit at a time. For some reason this is how most spigot algorithms do it, and so to me it "looks" correct. It doesn't actually change anything whatsoever other than when the standard output actually gets printed to console. --- Makefile.win | 2 +- Spigot.cpp | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Makefile.win b/Makefile.win index 989dcc4..cc803ff 100644 --- a/Makefile.win +++ b/Makefile.win @@ -2,7 +2,7 @@ CC=x86_64-w64-mingw32-gcc CXX=x86_64-w64-mingw32-g++ RM=rm -f CPPFLAGS=-Wall -LDFLAGS= +LDFLAGS=-static LDLIBS=-lm SRCS=main.cpp Spigot.cpp diff --git a/Spigot.cpp b/Spigot.cpp index 9e44b72..79228ed 100644 --- a/Spigot.cpp +++ b/Spigot.cpp @@ -39,7 +39,7 @@ void Spigot::pump(void) { // output all predigits long unsigned pdLen = this->preDigits.size(); for(long unsigned int j = 0; j < pdLen; j++) { - std::cout << this->preDigits.back() << std::flush; + std::cout << this->preDigits.back(); this->preDigits.pop_back(); } this->preDigits.insert(this->preDigits.begin(), tempPreDigit); @@ -50,7 +50,7 @@ void Spigot::pump(void) { tempPreDigit = 0; long unsigned pdLen = this->preDigits.size(); for(long unsigned int j = 0; j < pdLen; j++) { - std::cout << (this->preDigits.back() + 1) % 10 << std::flush; + std::cout << (this->preDigits.back() + 1) % 10; this->preDigits.pop_back(); } this->preDigits.insert(this->preDigits.begin(), tempPreDigit); @@ -60,5 +60,6 @@ void Spigot::pump(void) { } catch (int e) { std::cout << "An exception " << e << " occurred." << std::endl; } + std::cout << std::flush; return; }