Bump C std version to 11, and use static_assert

This commit is contained in:
x3 2021-05-04 18:34:35 +02:00
parent 502ad833fc
commit d4951e0a70
Signed by: x3
GPG Key ID: 7E9961E8AD0E240E
2 changed files with 4 additions and 6 deletions

View File

@ -2,7 +2,7 @@ MultiThread = Yes
PROGNAME = torrent-verify PROGNAME = torrent-verify
CC = cc 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 \ CPPFLAGS = -DPROGRAM_NAME='"$(PROGNAME)"' -DBUILD_INFO \
-DBUILD_HASH="\"`git rev-parse --abbrev-ref HEAD` -> `git rev-parse --short HEAD`\"" -DBUILD_DATE="\"`date -I`\"" -DBUILD_HASH="\"`git rev-parse --abbrev-ref HEAD` -> `git rev-parse --short HEAD`\"" -DBUILD_DATE="\"`date -I`\""

View File

@ -2,6 +2,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <assert.h>
#include "metainfo.h" #include "metainfo.h"
#include "verify.h" #include "verify.h"
#include "showinfo.h" #include "showinfo.h"
@ -11,6 +12,8 @@
#define PROGRAM_NAME "torrent-verify" #define PROGRAM_NAME "torrent-verify"
#endif #endif
static_assert((sizeof(long long) >= 8), "Size of long long is less than 8, cannot compile");
void usage() { void usage() {
fprintf(stderr, "Usage: " PROGRAM_NAME " [-h | -i | -s] [-n] [-v data_path] [--] .torrent_file...\n"); fprintf(stderr, "Usage: " PROGRAM_NAME " [-h | -i | -s] [-n] [-v data_path] [--] .torrent_file...\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
@ -43,11 +46,6 @@ BUILD_HASH " (" BUILD_DATE ")\n"
} }
int main(int argc, char** argv) { 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) if (opts_parse(argc, argv) == -1)
usage(); usage();