From 10ed00ef9b42514a8c8b231fba1e8d4f7e99efc3 Mon Sep 17 00:00:00 2001 From: "Samuel K. Gutierrez" Date: Tue, 26 Jan 2021 20:44:31 -0700 Subject: [PATCH] Fix compilation errors in mpi/halo3d* and mpi/sweep3d Add -D_POSIX_C_SOURCE=200809L to fix the following: * error: variable has incomplete type 'struct timespec' * warning: implicit declaration of function 'nanosleep' is invalid in C99 Tested using the following compilers on Fedora 30, Fedora 33: * gcc (GCC) 9.3.1 20200408 (Red Hat 9.3.1-2) * gcc (GCC) 10.2.1 20201125 (Red Hat 10.2.1-9) * clang version 8.0.0 (Fedora 8.0.0-3.fc30) Please see: https://man7.org/linux/man-pages//man2/nanosleep.2.html --- mpi/halo3d-26/Makefile | 3 ++- mpi/halo3d/Makefile | 3 ++- mpi/sweep3d/Makefile | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/mpi/halo3d-26/Makefile b/mpi/halo3d-26/Makefile index 4da3198..8e52353 100644 --- a/mpi/halo3d-26/Makefile +++ b/mpi/halo3d-26/Makefile @@ -1,10 +1,11 @@ CC=mpicc CFLAGS=-O3 -std=c99 +EXTRA_CFLAGS=-D_POSIX_C_SOURCE=200809L LIBS= halo3d-26: halo3d-26.c - $(CC) $(CFLAGS) -o $@ $< $(LIBS) + $(CC) $(CFLAGS) $(EXTRA_CFLAGS) -o $@ $< $(LIBS) clean: rm halo3d-26 diff --git a/mpi/halo3d/Makefile b/mpi/halo3d/Makefile index 87a06af..4314546 100644 --- a/mpi/halo3d/Makefile +++ b/mpi/halo3d/Makefile @@ -1,10 +1,11 @@ CC=mpicc CFLAGS=-O3 -std=c99 +EXTRA_CFLAGS=-D_POSIX_C_SOURCE=200809L LIBS= halo3d: halo3d.c - $(CC) $(CFLAGS) -o $@ $< $(LIBS) + $(CC) $(CFLAGS) $(EXTRA_CFLAGS) -o $@ $< $(LIBS) clean: rm halo3d diff --git a/mpi/sweep3d/Makefile b/mpi/sweep3d/Makefile index a5d3677..e39dbf7 100644 --- a/mpi/sweep3d/Makefile +++ b/mpi/sweep3d/Makefile @@ -1,10 +1,11 @@ CC=mpicc CFLAGS=-O3 -std=c99 +EXTRA_CFLAGS=-D_POSIX_C_SOURCE=200809L LIBS= sweep3d: sweep3d.c - $(CC) $(CFLAGS) -o $@ $< $(LIBS) + $(CC) $(CFLAGS) $(EXTRA_CFLAGS) -o $@ $< $(LIBS) clean: rm sweep3d