From d4951e0a7024dacb570f6ef5f26e372f6a173664 Mon Sep 17 00:00:00 2001 From: x3 Date: Tue, 4 May 2021 18:34:35 +0200 Subject: [PATCH] Bump C std version to 11, and use static_assert --- Makefile | 2 +- src/main.c | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index a0aef79..563e991 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ MultiThread = Yes PROGNAME = torrent-verify CC = cc -CFLAGS = -Wall -std=gnu99 -I./subm/heapless-bencode -Werror -O3 +CFLAGS = -Wall -std=gnu11 -I./subm/heapless-bencode -Werror -O3 CPPFLAGS = -DPROGRAM_NAME='"$(PROGNAME)"' -DBUILD_INFO \ -DBUILD_HASH="\"`git rev-parse --abbrev-ref HEAD` -> `git rev-parse --short HEAD`\"" -DBUILD_DATE="\"`date -I`\"" diff --git a/src/main.c b/src/main.c index 90923f9..97921ed 100644 --- a/src/main.c +++ b/src/main.c @@ -2,6 +2,7 @@ #include #include #include +#include #include "metainfo.h" #include "verify.h" #include "showinfo.h" @@ -11,6 +12,8 @@ #define PROGRAM_NAME "torrent-verify" #endif +static_assert((sizeof(long long) >= 8), "Size of long long is less than 8, cannot compile"); + void usage() { fprintf(stderr, "Usage: " PROGRAM_NAME " [-h | -i | -s] [-n] [-v data_path] [--] .torrent_file...\n"); exit(EXIT_FAILURE); @@ -43,11 +46,6 @@ BUILD_HASH " (" BUILD_DATE ")\n" } int main(int argc, char** argv) { - if (sizeof(long int) < 8) { - fprintf(stderr, "long int is less than 8 bytes. Create an issue please.\n"); - exit(1); - } - if (opts_parse(argc, argv) == -1) usage();