commit c27078ad75197699b6447298be154acf53b07bdf
parent c41c94106edc14432c31fbd42cb81842ef4b925b
Author: bsandro <email@bsandro.tech>
Date: Fri, 3 Jan 2025 00:45:12 +0200
%lld (int64_t) to PRIi64 (inttypes.h)
Diffstat:
3 files changed, 5 insertions(+), 6 deletions(-)
diff --git a/day13/main.cpp b/day13/main.cpp
@@ -1,3 +1,4 @@
+#include <inttypes.h>
#include <iostream>
#include <filesystem>
#include <fstream>
@@ -14,7 +15,7 @@ struct Vec2 {
int64_t y;
void fromStr(const std::string &s) {
[[ maybe_unused ]] char btn;
- std::sscanf(s.c_str(), "Button %c: X+%lld, Y+%lld", &btn, &x, &y);
+ std::sscanf(s.c_str(), "Button %c: X+%" PRIi64 ", Y+%" PRIi64, &btn, &x, &y);
}
bool operator==(const Vec2 &other) const {
return this->x==other.x && this->y==other.y;
@@ -29,10 +30,7 @@ struct Machine {
Vec2 btnB;
Vec2 prize;
void setPrize(const std::string &s) {
- std::sscanf(s.c_str(), "Prize: X=%lld, Y=%lld", &prize.x, &prize.y);
- }
- void print() const {
- std::printf("A(%lld,%lld), B(%lld,%lld), prize at (%lld,%lld)\n", btnA.x, btnA.y, btnB.x, btnB.y, prize.x, prize.y);
+ std::sscanf(s.c_str(), "Prize: X=%" PRIi64 ", Y=%" PRIi64, &prize.x, &prize.y);
}
};
diff --git a/day19/Makefile b/day19/Makefile
@@ -2,7 +2,7 @@ NAME=$(shell basename ${PWD})
SRC=$(wildcard *.cpp)
DEPS:=$(wildcard *.hpp)
OBJ:=$(SRC:.cpp=.o)
-CXXFLAGS=-O2 -std=c++23 -Werror -Wall -Wextra -I. -I../include
+CXXFLAGS=-Os -std=c++23 -Werror -Wall -Wextra -I. -I../include
LDFLAGS=-lstdc++
all: $(NAME)
diff --git a/tpl/main.cpp b/tpl/main.cpp
@@ -1,3 +1,4 @@
+#include <inttypes.h>
#include <iostream>
#include <filesystem>
#include <fstream>