From 16cbca261da950f0e3e887fd7fd068e44065b4fa Mon Sep 17 00:00:00 2001 From: Divye Kapoor Date: Tue, 9 May 2017 18:50:10 -0700 Subject: [PATCH 1/4] Add a test rule to the Makefile. --- Makefile | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index b6ed25e..c68c66b 100644 --- a/Makefile +++ b/Makefile @@ -14,14 +14,18 @@ OBJECTS=$(SOURCES:src/%.cpp=obj/%.o) EXECUTABLE=JSONDemo all: $(SOURCES) $(EXECUTABLE) - -$(EXECUTABLE): $(OBJECTS) + +$(EXECUTABLE): $(OBJECTS) $(CC) $(LFLAGS) $(OBJECTS) -o $@ obj/%.o: src/%.cpp $(HEADERS) @test -d $(@D) || mkdir -p $(@D) $(CC) $(CFLAGS) $(@:obj/%.o=src/%.cpp) -o $@ +test: $(EXECUTABLE) + ./JSONDemo -t + clean: rm -f $(OBJECTS) $(EXECUTABLE) +.PHONY: clean test From abcf1bae1df409179d67f35ad6d2183af75abba2 Mon Sep 17 00:00:00 2001 From: Divye Kapoor Date: Tue, 9 May 2017 19:01:13 -0700 Subject: [PATCH 2/4] Mark single argument constructors as explicit. This disallows implicit conversions of the form: JSONValue(pointer) => JSONValue(bool) JSONValue v = 23; etc. Tested: make test --- src/JSONValue.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/JSONValue.h b/src/JSONValue.h index 1e38228..5cfff18 100644 --- a/src/JSONValue.h +++ b/src/JSONValue.h @@ -40,13 +40,13 @@ class JSONValue public: JSONValue(/*NULL*/); - JSONValue(const wchar_t *m_char_value); - JSONValue(const std::wstring &m_string_value); - JSONValue(bool m_bool_value); - JSONValue(double m_number_value); - JSONValue(int m_integer_value); - JSONValue(const JSONArray &m_array_value); - JSONValue(const JSONObject &m_object_value); + explicit JSONValue(const wchar_t *m_char_value); + explicit JSONValue(const std::wstring &m_string_value); + explicit JSONValue(bool m_bool_value); + explicit JSONValue(double m_number_value); + explicit JSONValue(int m_integer_value); + explicit JSONValue(const JSONArray &m_array_value); + explicit JSONValue(const JSONObject &m_object_value); JSONValue(const JSONValue &m_source); ~JSONValue(); From 1f619b5844d845ef9112a179ea9f211af193cfce Mon Sep 17 00:00:00 2001 From: Divye Kapoor Date: Tue, 9 May 2017 19:05:01 -0700 Subject: [PATCH 3/4] Fix bad tab in Makefile. --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index c68c66b..9fd7412 100644 --- a/Makefile +++ b/Makefile @@ -23,7 +23,7 @@ obj/%.o: src/%.cpp $(HEADERS) $(CC) $(CFLAGS) $(@:obj/%.o=src/%.cpp) -o $@ test: $(EXECUTABLE) - ./JSONDemo -t + ./JSONDemo -t clean: rm -f $(OBJECTS) $(EXECUTABLE) From 16a40135b623e5ac422505d096769776298179ca Mon Sep 17 00:00:00 2001 From: Divye Kapoor Date: Tue, 9 May 2017 19:11:09 -0700 Subject: [PATCH 4/4] Use the EXECUTABLE variable in the Makefile. --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 9fd7412..3a427c3 100644 --- a/Makefile +++ b/Makefile @@ -23,7 +23,7 @@ obj/%.o: src/%.cpp $(HEADERS) $(CC) $(CFLAGS) $(@:obj/%.o=src/%.cpp) -o $@ test: $(EXECUTABLE) - ./JSONDemo -t + ./$(EXECUTABLE) -t clean: rm -f $(OBJECTS) $(EXECUTABLE)