From 9937bc9bb992a1e82bee93181796b4160e53ade9 Mon Sep 17 00:00:00 2001 From: Noel Maersk Date: Sun, 4 May 2014 18:14:57 +0300 Subject: [PATCH] Fix comparing argv, build with all warnings. Comparing `argv[1] == "-h"` doesn't work, since both are pointers to a char array. Type-casting one of them overloads `operator==` and allows using the conditional. Adding `-Wall`, just in case. P.S. Should be explicitly included?.. --- Makefile | 2 +- main.cpp | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index bc7e4f7..4a80b01 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,3 @@ default: - g++ main.cpp btcnet.cpp $(shell pkg-config --cflags --libs libczmq++ libbitcoin) -lboost_filesystem -o brc + g++ -Wall main.cpp btcnet.cpp $(shell pkg-config --cflags --libs libczmq++ libbitcoin) -lboost_filesystem -o brc diff --git a/main.cpp b/main.cpp index 6070f1b..6b453b6 100644 --- a/main.cpp +++ b/main.cpp @@ -35,7 +35,8 @@ void create_cert_if_not_exists(const std::string& filename) int main(int argc, char** argv) { - if (argc > 1 && (argv[1] == "-h" || argv[1] == "--help")) + if (argc > 1 && ((std::string)argv[1] == "-h" || + (std::string)argv[1] == "--help")) { log_info() << "Usage: brc [ZMQ_TRANSPORT] [CLIENT_CERTS_DIR]"; log_info() << "Example: brc tcp://*:8989";