diff --git a/configure.ac b/configure.ac
index d5d6045bf56b3585a98369997031d30f9e849742..2420d9accf40e42defb9e3995c587e6d042bc955 100644
--- a/configure.ac
+++ b/configure.ac
@@ -40,7 +40,7 @@ AX_CHECK_ENABLE_DEBUG
 AC_USE_SYSTEM_EXTENSIONS
 AC_PROG_CC
 AM_PROG_CC_C_O
-AC_OPENMP
+AX_OPENMP
 
 # If debug is selected then we also define SWIFT_DEVELOP_MODE to control
 # any developer code options.
diff --git a/m4/ax_openmp.m4 b/m4/ax_openmp.m4
new file mode 100644
index 0000000000000000000000000000000000000000..5d7469380f16fc6ca4b8d5ebf330aa81e12c0701
--- /dev/null
+++ b/m4/ax_openmp.m4
@@ -0,0 +1,123 @@
+# ===========================================================================
+#        https://www.gnu.org/software/autoconf-archive/ax_openmp.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+#   AX_OPENMP([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
+#
+# DESCRIPTION
+#
+#   This macro tries to find out how to compile programs that use OpenMP a
+#   standard API and set of compiler directives for parallel programming
+#   (see http://www-unix.mcs/)
+#
+#   On success, it sets the OPENMP_CFLAGS/OPENMP_CXXFLAGS/OPENMP_F77FLAGS
+#   output variable to the flag (e.g. -omp) used both to compile *and* link
+#   OpenMP programs in the current language.
+#
+#   NOTE: You are assumed to not only compile your program with these flags,
+#   but also link it with them as well.
+#
+#   If you want to compile everything with OpenMP, you should set:
+#
+#     CFLAGS="$CFLAGS $OPENMP_CFLAGS"
+#     #OR#  CXXFLAGS="$CXXFLAGS $OPENMP_CXXFLAGS"
+#     #OR#  FFLAGS="$FFLAGS $OPENMP_FFLAGS"
+#
+#   (depending on the selected language).
+#
+#   The user can override the default choice by setting the corresponding
+#   environment variable (e.g. OPENMP_CFLAGS).
+#
+#   ACTION-IF-FOUND is a list of shell commands to run if an OpenMP flag is
+#   found, and ACTION-IF-NOT-FOUND is a list of commands to run it if it is
+#   not found. If ACTION-IF-FOUND is not specified, the default action will
+#   define HAVE_OPENMP.
+#
+# LICENSE
+#
+#   Copyright (c) 2008 Steven G. Johnson <stevenj@alum.mit.edu>
+#   Copyright (c) 2015 John W. Peterson <jwpeterson@gmail.com>
+#   Copyright (c) 2016 Nick R. Papior <nickpapior@gmail.com>
+#
+#   This program is free software: you can redistribute it and/or modify it
+#   under the terms of the GNU General Public License as published by the
+#   Free Software Foundation, either version 3 of the License, or (at your
+#   option) any later version.
+#
+#   This program is distributed in the hope that it will be useful, but
+#   WITHOUT ANY WARRANTY; without even the implied warranty of
+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+#   Public License for more details.
+#
+#   You should have received a copy of the GNU General Public License along
+#   with this program. If not, see <https://www.gnu.org/licenses/>.
+#
+#   As a special exception, the respective Autoconf Macro's copyright owner
+#   gives unlimited permission to copy, distribute and modify the configure
+#   scripts that are the output of Autoconf when processing the Macro. You
+#   need not follow the terms of the GNU General Public License when using
+#   or distributing such scripts, even though portions of the text of the
+#   Macro appear in them. The GNU General Public License (GPL) does govern
+#   all other use of the material that constitutes the Autoconf Macro.
+#
+#   This special exception to the GPL applies to versions of the Autoconf
+#   Macro released by the Autoconf Archive. When you make and distribute a
+#   modified version of the Autoconf Macro, you may extend this special
+#   exception to the GPL to apply to your modified version as well.
+
+#serial 13
+
+AC_DEFUN([AX_OPENMP], [
+AC_PREREQ([2.69]) dnl for _AC_LANG_PREFIX
+
+AC_CACHE_CHECK([for OpenMP flag of _AC_LANG compiler], ax_cv_[]_AC_LANG_ABBREV[]_openmp, [save[]_AC_LANG_PREFIX[]FLAGS=$[]_AC_LANG_PREFIX[]FLAGS
+ax_cv_[]_AC_LANG_ABBREV[]_openmp=unknown
+# Flags to try:  -fopenmp (gcc), -mp (SGI & PGI),
+#                -qopenmp (icc>=15), -openmp (icc),
+#                -xopenmp (Sun), -omp (Tru64),
+#                -qsmp=omp (AIX),
+#                none
+ax_openmp_flags="-qopenmp -fopenmp -openmp -mp -xopenmp -omp -qsmp=omp none"
+if test "x$OPENMP_[]_AC_LANG_PREFIX[]FLAGS" != x; then
+  ax_openmp_flags="$OPENMP_[]_AC_LANG_PREFIX[]FLAGS $ax_openmp_flags"
+fi
+for ax_openmp_flag in $ax_openmp_flags; do
+  case $ax_openmp_flag in
+    none) []_AC_LANG_PREFIX[]FLAGS=$save[]_AC_LANG_PREFIX[] ;;
+    *) []_AC_LANG_PREFIX[]FLAGS="$save[]_AC_LANG_PREFIX[]FLAGS $ax_openmp_flag" ;;
+  esac
+  AC_LINK_IFELSE([AC_LANG_SOURCE([[
+@%:@include <omp.h>
+
+static void
+parallel_fill(int * data, int n)
+{
+  int i;
+@%:@pragma omp parallel for
+  for (i = 0; i < n; ++i)
+    data[i] = i;
+}
+
+int
+main()
+{
+  int arr[100000];
+  omp_set_num_threads(2);
+  parallel_fill(arr, 100000);
+  return 0;
+}
+]])],[ax_cv_[]_AC_LANG_ABBREV[]_openmp=$ax_openmp_flag; break],[])
+done
+[]_AC_LANG_PREFIX[]FLAGS=$save[]_AC_LANG_PREFIX[]FLAGS
+])
+if test "x$ax_cv_[]_AC_LANG_ABBREV[]_openmp" = "xunknown"; then
+  m4_default([$2],:)
+else
+  if test "x$ax_cv_[]_AC_LANG_ABBREV[]_openmp" != "xnone"; then
+    OPENMP_[]_AC_LANG_PREFIX[]FLAGS=$ax_cv_[]_AC_LANG_ABBREV[]_openmp
+  fi
+  m4_default([$1], [AC_DEFINE(HAVE_OPENMP,1,[Define if OpenMP is enabled])])
+fi
+])dnl AX_OPENMP
diff --git a/src/common_io.c b/src/common_io.c
index eea1d91fe2375190e15453e04d7075c976afafea..145eba9015802b8a5ecc871c16ddfd02bff37559 100644
--- a/src/common_io.c
+++ b/src/common_io.c
@@ -287,9 +287,9 @@ void io_read_array_attribute(hid_t grp, const char* name,
   /* Check if correct number of element */
   if (count != number_element) {
     error(
-        "Error found a different number of elements than expected (%lli != "
-        "%lli) in attribute %s",
-        count, number_element, name);
+        "Error found a different number of elements than expected (%llu != "
+        "%llu) in attribute %s",
+        (unsigned long long)count, (unsigned long long)number_element, name);
   }
 
   /* Read attribute */
@@ -358,9 +358,9 @@ void io_read_array_dataset(hid_t grp, const char* name, enum IO_DATA_TYPE type,
   /* Check if correct number of element */
   if (count != number_element) {
     error(
-        "Error found a different number of elements than expected (%lli != "
-        "%lli) in dataset %s",
-        count, number_element, name);
+        "Error found a different number of elements than expected (%llu != "
+        "%llu) in dataset %s",
+        (unsigned long long)count, (unsigned long long)number_element, name);
   }
 
   /* Read dataset */
diff --git a/src/distributed_io.c b/src/distributed_io.c
index d56cb1cd7b78335b298692500cd432c043e3f6c9..d2466030eae7635eddb2d4ec5830070e3557cd2c 100644
--- a/src/distributed_io.c
+++ b/src/distributed_io.c
@@ -169,7 +169,8 @@ void write_distributed_array(
     h_err = H5Pset_chunk(h_prop, rank, chunk_shape);
     if (h_err < 0)
       error("Error while setting chunk size (%llu, %llu) for field '%s'.",
-            chunk_shape[0], chunk_shape[1], props.name);
+            (unsigned long long)chunk_shape[0],
+            (unsigned long long)chunk_shape[1], props.name);
 
     /* Are we imposing some form of lossy compression filter? */
     if (lossy_compression != compression_write_lossless)
diff --git a/src/fof_catalogue_io.c b/src/fof_catalogue_io.c
index e437492209b65d405fa0331b5c08c9d4cde9b76b..393792ded0ee2c50c22f455a8de8088246ef73ac 100644
--- a/src/fof_catalogue_io.c
+++ b/src/fof_catalogue_io.c
@@ -208,7 +208,8 @@ void write_fof_hdf5_array(
     h_err = H5Pset_chunk(h_prop, rank, chunk_shape);
     if (h_err < 0)
       error("Error while setting chunk size (%llu, %llu) for field '%s'.",
-            chunk_shape[0], chunk_shape[1], props.name);
+            (unsigned long long)chunk_shape[0],
+            (unsigned long long)chunk_shape[1], props.name);
 
     /* Are we imposing some form of lossy compression filter? */
     if (lossy_compression != compression_write_lossless)
diff --git a/src/line_of_sight.c b/src/line_of_sight.c
index e90eea141b23281ac382e5d776a89f48260e7a22..d0ea412558242f14f2ac560fb658ab69962438cc 100644
--- a/src/line_of_sight.c
+++ b/src/line_of_sight.c
@@ -316,7 +316,8 @@ void write_los_hdf5_dataset(const struct io_props props, const size_t N,
   h_err = H5Pset_chunk(h_prop, rank, chunk_shape);
   if (h_err < 0)
     error("Error while setting chunk size (%llu, %llu) for field '%s'.",
-          chunk_shape[0], chunk_shape[1], props.name);
+          (unsigned long long)chunk_shape[0],
+          (unsigned long long)chunk_shape[1], props.name);
 
   /* Impose check-sum to verify data corruption */
   h_err = H5Pset_fletcher32(h_prop);
diff --git a/src/single_io.c b/src/single_io.c
index 0ae8ef42ad5fa4bce27ca6fd51906a00de81305f..3a8e17a938249c04345826db23062c2296222d28 100644
--- a/src/single_io.c
+++ b/src/single_io.c
@@ -302,7 +302,8 @@ void write_array_single(const struct engine* e, hid_t grp, const char* fileName,
     h_err = H5Pset_chunk(h_prop, rank, chunk_shape);
     if (h_err < 0)
       error("Error while setting chunk size (%llu, %llu) for field '%s'.",
-            chunk_shape[0], chunk_shape[1], props.name);
+            (unsigned long long)chunk_shape[0],
+            (unsigned long long)chunk_shape[1], props.name);
   }
 
   /* Are we imposing some form of lossy compression filter? */
diff --git a/src/space_extras.c b/src/space_extras.c
index c06560671cbfdd772c076c6ba2b760cce532b88c..9d8a88952e5a3d2a670ba63f96001dc27eda26c7 100644
--- a/src/space_extras.c
+++ b/src/space_extras.c
@@ -184,7 +184,9 @@ void space_allocate_extras(struct space *s, int verbose) {
     size_t local_cell_id = 0;
     int current_cell = local_cells[local_cell_id];
     int count_in_cell = 0;
+#ifdef SWIFT_DEBUG_CHECKS
     size_t count_extra_gparts = 0;
+#endif
     for (size_t i = 0; i < nr_actual_gparts + expected_num_extra_gparts; ++i) {
 
 #ifdef SWIFT_DEBUG_CHECKS
@@ -199,7 +201,9 @@ void space_allocate_extras(struct space *s, int verbose) {
         s->gparts[i].x[1] = cells[current_cell].loc[1] + half_cell_width[1];
         s->gparts[i].x[2] = cells[current_cell].loc[2] + half_cell_width[2];
         ++count_in_cell;
+#ifdef SWIFT_DEBUG_CHECKS
         count_extra_gparts++;
+#endif
       }
 
       /* Once we have reached the number of extra gpart per cell, we move to the
@@ -276,7 +280,9 @@ void space_allocate_extras(struct space *s, int verbose) {
     size_t local_cell_id = 0;
     int current_cell = local_cells[local_cell_id];
     int count_in_cell = 0;
+#ifdef SWIFT_DEBUG_CHECKS
     size_t count_extra_parts = 0;
+#endif
     for (size_t i = 0; i < nr_actual_parts + expected_num_extra_parts; ++i) {
 
 #ifdef SWIFT_DEBUG_CHECKS
@@ -291,7 +297,9 @@ void space_allocate_extras(struct space *s, int verbose) {
         s->parts[i].x[1] = cells[current_cell].loc[1] + half_cell_width[1];
         s->parts[i].x[2] = cells[current_cell].loc[2] + half_cell_width[2];
         ++count_in_cell;
+#ifdef SWIFT_DEBUG_CHECKS
         count_extra_parts++;
+#endif
       }
 
       /* Once we have reached the number of extra part per cell, we move to the
@@ -357,7 +365,9 @@ void space_allocate_extras(struct space *s, int verbose) {
     size_t local_cell_id = 0;
     int current_cell = local_cells[local_cell_id];
     int count_in_cell = 0;
+#ifdef SWIFT_DEBUG_CHECKS
     size_t count_extra_sinks = 0;
+#endif
     for (size_t i = 0; i < nr_actual_sinks + expected_num_extra_sinks; ++i) {
 
 #ifdef SWIFT_DEBUG_CHECKS
@@ -372,7 +382,9 @@ void space_allocate_extras(struct space *s, int verbose) {
         s->sinks[i].x[1] = cells[current_cell].loc[1] + half_cell_width[1];
         s->sinks[i].x[2] = cells[current_cell].loc[2] + half_cell_width[2];
         ++count_in_cell;
+#ifdef SWIFT_DEBUG_CHECKS
         count_extra_sinks++;
+#endif
       }
 
       /* Once we have reached the number of extra sink per cell, we move to the
@@ -439,7 +451,9 @@ void space_allocate_extras(struct space *s, int verbose) {
     size_t local_cell_id = 0;
     int current_cell = local_cells[local_cell_id];
     int count_in_cell = 0;
+#ifdef SWIFT_DEBUG_CHECKS
     size_t count_extra_sparts = 0;
+#endif
     for (size_t i = 0; i < nr_actual_sparts + expected_num_extra_sparts; ++i) {
 
 #ifdef SWIFT_DEBUG_CHECKS
@@ -454,7 +468,9 @@ void space_allocate_extras(struct space *s, int verbose) {
         s->sparts[i].x[1] = cells[current_cell].loc[1] + half_cell_width[1];
         s->sparts[i].x[2] = cells[current_cell].loc[2] + half_cell_width[2];
         ++count_in_cell;
+#ifdef SWIFT_DEBUG_CHECKS
         count_extra_sparts++;
+#endif
       }
 
       /* Once we have reached the number of extra spart per cell, we move to the
@@ -521,7 +537,9 @@ void space_allocate_extras(struct space *s, int verbose) {
     size_t local_cell_id = 0;
     int current_cell = local_cells[local_cell_id];
     int count_in_cell = 0;
+#ifdef SWIFT_DEBUG_CHECKS
     size_t count_extra_bparts = 0;
+#endif
     for (size_t i = 0; i < nr_actual_bparts + expected_num_extra_bparts; ++i) {
 
 #ifdef SWIFT_DEBUG_CHECKS
@@ -536,7 +554,9 @@ void space_allocate_extras(struct space *s, int verbose) {
         s->bparts[i].x[1] = cells[current_cell].loc[1] + half_cell_width[1];
         s->bparts[i].x[2] = cells[current_cell].loc[2] + half_cell_width[2];
         ++count_in_cell;
+#ifdef SWIFT_DEBUG_CHECKS
         count_extra_bparts++;
+#endif
       }
 
       /* Once we have reached the number of extra bpart per cell, we move to the
diff --git a/src/task.c b/src/task.c
index c290bbb11cc4f4f0483b6eb44b578964577c8eb7..333f648769db702651f6438d2a8a3cf9c34de5b2 100644
--- a/src/task.c
+++ b/src/task.c
@@ -1670,7 +1670,6 @@ void task_dump_active(struct engine *e) {
   fprintf(file_thread, "%i 0 none none -1 0 %lld %lld %lld %lld %lld 0 %lld\n",
           engine_rank, (long long int)e->tic_step, (long long int)e->toc_step,
           e->updates, e->g_updates, e->s_updates, cpufreq);
-  int count = 0;
   for (int l = 0; l < e->sched.nr_tasks; l++) {
     struct task *t = &e->sched.tasks[l];
 
@@ -1691,7 +1690,6 @@ void task_dump_active(struct engine *e) {
               (t->ci != NULL) ? t->ci->grav.count : 0,
               (t->cj != NULL) ? t->cj->grav.count : 0, t->flags);
     }
-    count++;
   }
   fclose(file_thread);
 
diff --git a/src/threadpool.c b/src/threadpool.c
index 632ac917a349af34e24f7b720f7ed0d65727de3a..5fddd59ae833bf0a8de8ac3024cfa7baad987090 100644
--- a/src/threadpool.c
+++ b/src/threadpool.c
@@ -424,7 +424,7 @@ void threadpool_clean(struct threadpool *tp) {
 /**
  * @brief return the threadpool id of the current thread.
  */
-int threadpool_gettid() {
+int threadpool_gettid(void) {
   int *tid = (int *)pthread_getspecific(threadpool_tid);
   return *tid;
 }
diff --git a/src/tools.c b/src/tools.c
index d771016591371d64b6adc1bc85169021ef262fef..022c3fb3b64aa432332e3e137e2ae7a220b91d3b 100644
--- a/src/tools.c
+++ b/src/tools.c
@@ -1030,7 +1030,7 @@ int compare_particles(struct part *a, struct part *b, double threshold) {
  *
  * @result memory use in Kb.
  */
-long get_maxrss() {
+long get_maxrss(void) {
   struct rusage usage;
   getrusage(RUSAGE_SELF, &usage);
   return usage.ru_maxrss;