comply with -std=c17
This commit is contained in:
parent
f64646b40b
commit
f1b30b697e
@ -3,7 +3,7 @@
|
|||||||
cmake_minimum_required(VERSION 3.10)
|
cmake_minimum_required(VERSION 3.10)
|
||||||
project(simworld VERSION 0.0.1 LANGUAGES C)
|
project(simworld VERSION 0.0.1 LANGUAGES C)
|
||||||
|
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wformat=2 -Wshadow -Wwrite-strings -Wstrict-prototypes -g")
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -std=c17 -Wpedantic -pedantic-errors -Wformat=2 -Wshadow -Wwrite-strings -Wstrict-prototypes -g")
|
||||||
|
|
||||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
// sock.c
|
// sock.c
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <sys/un.h>
|
#include <sys/un.h>
|
||||||
|
@ -17,10 +17,12 @@ enum error_t entity_registrant_init(
|
|||||||
|
|
||||||
if (name == NULL || strlen(name) > MAX_NAME_LENGTH) return ERR_INPUT;
|
if (name == NULL || strlen(name) > MAX_NAME_LENGTH) return ERR_INPUT;
|
||||||
|
|
||||||
char const *dup = strndup(name, MAX_NAME_LENGTH);
|
char *namecpy = calloc(MAX_NAME_LENGTH, sizeof(char));
|
||||||
if (dup == NULL) return ERR_ALLOC;
|
if (namecpy == NULL) return ERR_ALLOC;
|
||||||
|
|
||||||
self->name = dup;
|
strncpy(namecpy, name, MAX_NAME_LENGTH);
|
||||||
|
|
||||||
|
self->name = namecpy;
|
||||||
self->tile = tile;
|
self->tile = tile;
|
||||||
|
|
||||||
return ERR_OK;
|
return ERR_OK;
|
||||||
@ -67,9 +69,9 @@ enum error_t entity_registry_append(
|
|||||||
assert(self != NULL && registrant != NULL);
|
assert(self != NULL && registrant != NULL);
|
||||||
|
|
||||||
self->size += 1;
|
self->size += 1;
|
||||||
self->entities = reallocarray(
|
self->entities = realloc(
|
||||||
self->entities, self->size,
|
self->entities,
|
||||||
sizeof(struct entity_registrant_t)
|
self->size * sizeof(struct entity_registrant_t)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (self->entities == NULL) return ERR_ALLOC;
|
if (self->entities == NULL) return ERR_ALLOC;
|
||||||
|
@ -14,7 +14,9 @@
|
|||||||
#include "sock.h"
|
#include "sock.h"
|
||||||
#include "data.h"
|
#include "data.h"
|
||||||
|
|
||||||
static void handle_signal(int _) {
|
static void handle_signal(int signal_no) {
|
||||||
|
(void)signal_no;
|
||||||
|
|
||||||
remove(SOCK_PATH);
|
remove(SOCK_PATH);
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
@ -60,7 +62,7 @@ int main(int argc, char **argv) {
|
|||||||
if (err) goto handle_error_world;
|
if (err) goto handle_error_world;
|
||||||
|
|
||||||
// Temporary code because I just realised I need to properly serialise
|
// Temporary code because I just realised I need to properly serialise
|
||||||
// data because don't work cross-socket
|
// data because pointers don't work cross-socket
|
||||||
// TODO: Serialise to JSON
|
// TODO: Serialise to JSON
|
||||||
const char *fmt = "%zu (%s) (%zu, %zu) '%c'\n";
|
const char *fmt = "%zu (%s) (%zu, %zu) '%c'\n";
|
||||||
struct entity_t const *const entity = &data.world.entities[0];
|
struct entity_t const *const entity = &data.world.entities[0];
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <sys/un.h>
|
#include <sys/un.h>
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
enum error_t sock_init(int *);
|
enum error_t sock_init(int *);
|
||||||
void sock_free(int const *);
|
void sock_free(int const *);
|
||||||
|
|
||||||
typedef enum error_t (* gameloop_fn)(struct data_t *);;
|
typedef enum error_t (* gameloop_fn)(struct data_t *);
|
||||||
enum error_t sock_loop(struct data_t *, gameloop_fn);
|
enum error_t sock_loop(struct data_t *, gameloop_fn);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user