gnuastro-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnuastro-commits] master bcd59d5 1/2: %zu instead of %lu for printing s


From: Mohammad Akhlaghi
Subject: [gnuastro-commits] master bcd59d5 1/2: %zu instead of %lu for printing size_t
Date: Mon, 10 Oct 2016 10:51:51 +0000 (UTC)

branch: master
commit bcd59d5b88860cd59a65d9fd4c3ed365323dea24
Author: Mohammad Akhlaghi <address@hidden>
Commit: Mohammad Akhlaghi <address@hidden>

    %zu instead of %lu for printing size_t
    
    GNU Guix recently updated their Gnuastro build to 0.2. The build for
    `i686-linux' on their system had failed because of using `%lu' for printing
    `size_t' type variables. The problem is that on 32bit systems, `size_t' is
    32bit (so `%u' should be used), but on 64-bit systems we should be using
    `%lu'. Fortunately in C99, `printf' has the `z' modifier precisely for this
    problem with `size_t'. So all occurances of printing with `lu' have been
    changed to `zu'.
---
 bin/TEMPLATE/ui.c              |    2 +-
 bin/arithmetic/arithmetic.c    |    8 ++---
 bin/arithmetic/ui.c            |    4 +--
 bin/convertt/convertt.c        |    8 ++---
 bin/convertt/eps.c             |   26 ++++++++--------
 bin/convertt/jpeg.c            |   12 ++++----
 bin/convertt/ui.c              |   16 +++++-----
 bin/convolve/convolve.c        |   16 +++++-----
 bin/convolve/ui.c              |   16 +++++-----
 bin/cosmiccal/ui.c             |    2 +-
 bin/header/ui.c                |    8 ++---
 bin/imgcrop/crop.c             |   22 +++++++-------
 bin/imgcrop/imgcrop.c          |    8 ++---
 bin/imgcrop/ui.c               |   28 +++++++++---------
 bin/imgcrop/wcsmode.c          |    2 +-
 bin/imgstat/imgstat.c          |    2 +-
 bin/imgstat/main.h             |    2 +-
 bin/imgstat/ui.c               |    8 ++---
 bin/imgwarp/imgwarp.c          |   20 ++++++-------
 bin/imgwarp/ui.c               |   28 +++++++++---------
 bin/mkcatalog/columns.c        |   34 ++++++++++-----------
 bin/mkcatalog/mkcatalog.c      |   14 ++++-----
 bin/mkcatalog/ui.c             |   30 +++++++++----------
 bin/mkcatalog/upperlimit.c     |   22 +++++++-------
 bin/mknoise/ui.c               |    4 +--
 bin/mkprof/mkprof.c            |   16 +++++-----
 bin/mkprof/oneprofile.c        |    6 ++--
 bin/mkprof/ui.c                |   50 +++++++++++++++----------------
 bin/noisechisel/binary.c       |    4 +--
 bin/noisechisel/clumps.c       |   22 +++++++-------
 bin/noisechisel/detection.c    |   22 +++++++-------
 bin/noisechisel/label.c        |   22 +++++++-------
 bin/noisechisel/noisechisel.c  |   10 +++----
 bin/noisechisel/segmentation.c |   28 +++++++++---------
 bin/noisechisel/thresh.c       |   10 +++----
 bin/noisechisel/ui.c           |   50 +++++++++++++++----------------
 bin/subtractsky/subtractsky.c  |    2 +-
 bin/subtractsky/ui.c           |   20 ++++++-------
 bin/table/table.c              |   36 +++++++++++-----------
 bin/table/ui.c                 |   42 +++++++++++++-------------
 doc/gnuastro.texi              |    2 +-
 lib/array.c                    |    6 ++--
 lib/checkset.c                 |   12 ++++----
 lib/checkset.h                 |   10 +++----
 lib/configfiles.h              |    2 +-
 lib/fits.c                     |   48 +++++++++++++++---------------
 lib/git.c                      |    2 +-
 lib/linkedlist.c               |   16 +++++-----
 lib/mesh.c                     |   64 ++++++++++++++++++++--------------------
 lib/mode.c                     |    8 ++---
 lib/polygon.c                  |   16 +++++-----
 lib/spatialconvolve.c          |    6 ++--
 lib/statistics.c               |   28 +++++++++---------
 lib/threads.c                  |    4 +--
 lib/txtarray.c                 |   16 +++++-----
 tests/lib/arraymanip.c         |    2 +-
 tests/lib/multithread.c        |    6 ++--
 57 files changed, 465 insertions(+), 465 deletions(-)

diff --git a/bin/TEMPLATE/ui.c b/bin/TEMPLATE/ui.c
index 7cd2d1c..9f16a59 100644
--- a/bin/TEMPLATE/ui.c
+++ b/bin/TEMPLATE/ui.c
@@ -98,7 +98,7 @@ readconfig(char *filename, struct TEMPLATEparams *p)
   errno=0;
   line=malloc(len*sizeof *line);
   if(line==NULL)
-    error(EXIT_FAILURE, errno, "ui.c: %lu bytes in readdefaults",
+    error(EXIT_FAILURE, errno, "ui.c: %zu bytes in readdefaults",
           len * sizeof *line);
 
   /* Read the tokens in the file:  */
diff --git a/bin/arithmetic/arithmetic.c b/bin/arithmetic/arithmetic.c
index 94c750e..cff9ee4 100644
--- a/bin/arithmetic/arithmetic.c
+++ b/bin/arithmetic/arithmetic.c
@@ -146,8 +146,8 @@ pop_operand(struct imgarithparams *p, double *number, 
double **array,
       else
         {
           if(p->s0!=s0 || p->s1!=s1)
-            error(EXIT_FAILURE, 0, "%s (hdu=%s): has size of %lu x %lu. "
-                  "However, previous images had a size of %lu x %lu. All "
+            error(EXIT_FAILURE, 0, "%s (hdu=%s): has size of %zu x %zu. "
+                  "However, previous images had a size of %zu x %zu. All "
                   "the images must be the same size in order for "
                   "ImageArithmetic to work", filename, hdu, s0, s1,
                   p->s0, p->s1);
@@ -477,12 +477,12 @@ alloppixs(struct imgarithparams *p, char *operator)
   errno=0;
   allarrays=malloc(numop*sizeof *allarrays);
   if(allarrays==NULL)
-    error(EXIT_FAILURE, errno, "%lu bytes for allarrays in alloppixs",
+    error(EXIT_FAILURE, errno, "%zu bytes for allarrays in alloppixs",
           numop*sizeof *allarrays);
   errno=0;
   allpixels=malloc(numop*sizeof *allpixels);
   if(allpixels==NULL)
-    error(EXIT_FAILURE, errno, "%lu bytes for allpixels in alloppixs",
+    error(EXIT_FAILURE, errno, "%zu bytes for allpixels in alloppixs",
           numop*sizeof *allpixels);
 
 
diff --git a/bin/arithmetic/ui.c b/bin/arithmetic/ui.c
index 50ac6e6..8caf5cf 100644
--- a/bin/arithmetic/ui.c
+++ b/bin/arithmetic/ui.c
@@ -89,7 +89,7 @@ readconfig(char *filename, struct imgarithparams *p)
   errno=0;
   line=malloc(len*sizeof *line);
   if(line==NULL)
-    error(EXIT_FAILURE, errno, "ui.c: %lu bytes in readdefaults",
+    error(EXIT_FAILURE, errno, "ui.c: %zu bytes in readdefaults",
           len * sizeof *line);
 
   /* Read the tokens in the file:  */
@@ -213,7 +213,7 @@ checkifset(struct imgarithparams *p)
      then re-run arithmetic. The best way is to simply ignore them. */
   if(numhdus<p->numfits)
     {
-      sprintf(comment, "hdu (%lu FITS file(s), %lu HDUs)",
+      sprintf(comment, "hdu (%zu FITS file(s), %zu HDUs)",
               p->numfits, numhdus);
       GAL_CONFIGFILES_REPORT_NOTSET(comment);
     }
diff --git a/bin/convertt/convertt.c b/bin/convertt/convertt.c
index 01096bd..850bfc7 100644
--- a/bin/convertt/convertt.c
+++ b/bin/convertt/convertt.c
@@ -61,7 +61,7 @@ changevalue(struct converttparams *p)
   to=malloc(numchange*sizeof *to);
   from=malloc(numchange*sizeof *from);
   if(to==NULL || from==NULL)
-    error(EXIT_FAILURE, errno, "%lu bytes for `to` or `from` in convert",
+    error(EXIT_FAILURE, errno, "%zu bytes for `to` or `from` in convert",
           numchange*sizeof *from);
   i=1;
   tmp=p->change;
@@ -188,7 +188,7 @@ savetxt(struct converttparams *p)
 
 
   /* Find the input file name and  */
-  sprintf(comments, "# Pixel values of %s (%lu x %lu pixels).\n"
+  sprintf(comments, "# Pixel values of %s (%zu x %zu pixels).\n"
           "# Created on %s# %s", p->names[0], p->s0[0], p->s1[0],
           ctime(&p->rawtime), SPACK_STRING);
 
@@ -224,7 +224,7 @@ savefits(struct converttparams *p)
         array=p->ch[i];
 
       /* Write array to a FITS file.*/
-      sprintf(hdu, "Channel%lu", i+1);
+      sprintf(hdu, "Channel%zu", i+1);
       gal_fits_array_to_file(p->cp.output, hdu, p->bitpixs[i], array,
                              p->s0[i], p->s1[i], 0, NULL, NULL,
                              SPACK_STRING);
@@ -271,7 +271,7 @@ doubleto8bit(struct converttparams *p)
       errno=0;
       ech[i]=malloc(size*sizeof *ech[i]);
       if(ech[i]==NULL)
-        error(EXIT_FAILURE, errno, "%lu bytes for ech[%lu]",
+        error(EXIT_FAILURE, errno, "%zu bytes for ech[%zu]",
               size*sizeof *ech[i], i);
     }
 
diff --git a/bin/convertt/eps.c b/bin/convertt/eps.c
index f0fc02e..336ab9e 100644
--- a/bin/convertt/eps.c
+++ b/bin/convertt/eps.c
@@ -182,7 +182,7 @@ blackandwhite(struct converttparams *p)
   errno=0;
   bits=calloc(bytesinimg, sizeof *bits);
   if(bits==NULL)
-    error(EXIT_FAILURE, errno, "allocating %lu bytes in blackandwhite",
+    error(EXIT_FAILURE, errno, "allocating %zu bytes in blackandwhite",
           bytesinimg);
 
   for(i=0;i<s0;++i)
@@ -223,7 +223,7 @@ channelsinhex(struct converttparams *p, FILE *fp, size_t 
size)
   for(i=0;i<p->numch;++i)
     {
       if(p->isblank[i])
-        fprintf(fp, "{<00>} %% Channel %lu is blank\n", i);
+        fprintf(fp, "{<00>} %% Channel %zu is blank\n", i);
       else
         {
           ech=p->ech[i];
@@ -252,7 +252,7 @@ channelsinascii85(struct converttparams *p, FILE *fp, 
size_t size)
   for(i=0;i<p->numch;++i)
     {
       if(p->isblank[i])
-        fprintf(fp, "{<00>} %% Channel %lu is blank\n", i);
+        fprintf(fp, "{<00>} %% Channel %zu is blank\n", i);
       else
         {
           ech=p->ech[i];
@@ -323,9 +323,9 @@ writeepsimage(struct converttparams *p, FILE *fp)
           "and fix it");
   fprintf(fp, "<<\n");
   fprintf(fp, "  /ImageType 1\n");
-  fprintf(fp, "  /Width %lu\n", p->s1[0]);
-  fprintf(fp, "  /Height %lu\n", p->s0[0]);
-  fprintf(fp, "  /ImageMatrix [ %lu 0 0 %lu 0 0 ]\n", p->s1[0], p->s0[0]);
+  fprintf(fp, "  /Width %zu\n", p->s1[0]);
+  fprintf(fp, "  /Height %zu\n", p->s0[0]);
+  fprintf(fp, "  /ImageMatrix [ %zu 0 0 %zu 0 0 ]\n", p->s1[0], p->s0[0]);
   fprintf(fp, "  /MultipleDataSources true\n");
   fprintf(fp, "  /BitsPerComponent %d\n", bpc);
   fprintf(fp, "  /Decode[");
@@ -382,7 +382,7 @@ saveepsorpdf(struct converttparams *p)
   if(fp==NULL)
     error(EXIT_FAILURE, errno, "%s", p->cp.output);
   fprintf(fp, "%%!PS-Adobe-3.0 EPSF-3.0\n");
-  fprintf(fp, "%%%%BoundingBox: 0 0 %lu %lu\n", winpt+2*p->borderwidth,
+  fprintf(fp, "%%%%BoundingBox: 0 0 %zu %zu\n", winpt+2*p->borderwidth,
           hinpt+2*p->borderwidth);
   fprintf(fp, "%%%%Creator: %s\n", SPACK_STRING);
   fprintf(fp, "%%%%CreationDate: %s", ctime(&p->rawtime));
@@ -400,9 +400,9 @@ saveepsorpdf(struct converttparams *p)
       fprintf(fp, "0 setgray\n");
       fprintf(fp, "%d setlinewidth\n", p->borderwidth);
       fprintf(fp, "%.1f %.1f moveto\n", hbw, hbw);
-      fprintf(fp, "0 %lu rlineto\n", hinpt+p->borderwidth);
-      fprintf(fp, "%lu 0 rlineto\n", winpt+p->borderwidth);
-      fprintf(fp, "0 -%lu rlineto\n", hinpt+p->borderwidth);
+      fprintf(fp, "0 %zu rlineto\n", hinpt+p->borderwidth);
+      fprintf(fp, "%zu 0 rlineto\n", winpt+p->borderwidth);
+      fprintf(fp, "0 -%zu rlineto\n", hinpt+p->borderwidth);
       fprintf(fp, "closepath\n");
       fprintf(fp, "stroke\n\n");
     }
@@ -412,7 +412,7 @@ saveepsorpdf(struct converttparams *p)
   /* Write the image: */
   fprintf(fp, "%% Draw the image:\n");
   fprintf(fp, "%d %d translate\n", p->borderwidth, p->borderwidth);
-  fprintf(fp, "%lu %lu scale\n", winpt, hinpt);
+  fprintf(fp, "%zu %zu scale\n", winpt, hinpt);
   writeepsimage(p, fp);
 
 
@@ -429,8 +429,8 @@ saveepsorpdf(struct converttparams *p)
 
   if(p->outputtype==PDFFORMAT)
     {
-      sprintf(command, "gs -q -o %s -sDEVICE=pdfwrite -dDEVICEWIDTHPOINTS=%lu"
-              " -dDEVICEHEIGHTPOINTS=%lu -dPDFFitPage %s", p->cp.output,
+      sprintf(command, "gs -q -o %s -sDEVICE=pdfwrite -dDEVICEWIDTHPOINTS=%zu"
+              " -dDEVICEHEIGHTPOINTS=%zu -dPDFFitPage %s", p->cp.output,
               winpt+2*p->borderwidth, hinpt+2*p->borderwidth, epsfilename);
       if(system(command))
         error(EXIT_FAILURE, 0, "the command to convert a PostScript file to "
diff --git a/bin/convertt/jpeg.c b/bin/convertt/jpeg.c
index 27c2477..0ac474f 100644
--- a/bin/convertt/jpeg.c
+++ b/bin/convertt/jpeg.c
@@ -148,7 +148,7 @@ makejsample(JSAMPLE **a, size_t size)
   errno=0;
   jsarr=malloc(size*sizeof *jsarr);
   if(jsarr==NULL)
-    error(EXIT_FAILURE, errno, "%lu bytes for jsarr", size*sizeof *jsarr);
+    error(EXIT_FAILURE, errno, "%zu bytes for jsarr", size*sizeof *jsarr);
 
   *a=jsarr;
 }
@@ -203,13 +203,13 @@ readjpg(char *inname, size_t *outs0, size_t *outs1, 
size_t *numcolors)
   errno=0;
   all=malloc(nc*sizeof *all);
   if(all==NULL)
-    error(EXIT_FAILURE, errno, "%lu bytes for all", nc*sizeof *all);
+    error(EXIT_FAILURE, errno, "%zu bytes for all", nc*sizeof *all);
   for(i=0;i<nc;++i)
     {
       errno=0;
       all[i]=malloc(s0*s1*sizeof *all[i]);
       if(all[i]==NULL)
-        error(EXIT_FAILURE, errno, "%lu bytes for all[%lu]",
+        error(EXIT_FAILURE, errno, "%zu bytes for all[%zu]",
               s0*s1*sizeof *all[i], i);
     }
 
@@ -333,7 +333,7 @@ writejpeg(JSAMPLE *jsr, struct converttparams *p)
       break;
     default:
       error(EXIT_FAILURE, 0, "a bug! The number of channels in writejpeg "
-            "is not 1, 3 or 4, but %lu. This should not happen. Please "
+            "is not 1, 3 or 4, but %zu. This should not happen. Please "
             "contact us so we can fix the problem", p->numch);
     }
 
@@ -375,7 +375,7 @@ savejpeg(struct converttparams *p)
   errno=0;
   jsr=malloc(size*sizeof *jsr);
   if(jsr==NULL)
-    error(EXIT_FAILURE, errno, "%lu bytes for jsr", size*sizeof *jsr);
+    error(EXIT_FAILURE, errno, "%zu bytes for jsr", size*sizeof *jsr);
 
   /* Write the different colors into jsr. */
   size=p->s0[0]*p->s1[0];
@@ -384,7 +384,7 @@ savejpeg(struct converttparams *p)
       {
         jsr[pixel*numch+color]=ech[color][pixel];
         /*
-        printf("color: %lu, pixel: %lu, jsr: %d\n", color, pixel,
+        printf("color: %zu, pixel: %zu, jsr: %d\n", color, pixel,
                (int)jsr[pixel*numch+color]);
         */
       }
diff --git a/bin/convertt/ui.c b/bin/convertt/ui.c
index 1ba3209..184c074 100644
--- a/bin/convertt/ui.c
+++ b/bin/convertt/ui.c
@@ -85,7 +85,7 @@ readconfig(char *filename, struct converttparams *p)
   errno=0;
   line=malloc(len*sizeof *line);
   if(line==NULL)
-    error(EXIT_FAILURE, errno, "ui.c: %lu bytes in readdefaults",
+    error(EXIT_FAILURE, errno, "ui.c: %zu bytes in readdefaults",
           len * sizeof *line);
 
   /* Read the tokens in the file:  */
@@ -298,7 +298,7 @@ makechangestruct(char *arg)
       while(*p==' ') {++p; continue;} /* Skip all space characters. */
       errno=0;
       c=malloc(sizeof *c);
-      if(c==NULL) error(EXIT_FAILURE, 0, "%lu bytes for struct change",
+      if(c==NULL) error(EXIT_FAILURE, 0, "%zu bytes for struct change",
                         sizeof *c);
       c->from=strtof(p, &p);
       while(*p==' ') {++p; continue;}
@@ -379,7 +379,7 @@ adddotautomaticoutput(struct converttparams *p)
       errno=0;
       tmp=malloc(strlen(cp->output)+10*sizeof *tmp);
       if(tmp==NULL)
-        error(EXIT_FAILURE, errno, "%lu bytes for suffix name",
+        error(EXIT_FAILURE, errno, "%zu bytes for suffix name",
               strlen(cp->output)+10*sizeof *tmp);
       sprintf(tmp, ".%s", cp->output);
       free(cp->output);
@@ -413,7 +413,7 @@ sanitycheck(struct converttparams *p)
   if(p->numch!=1 && p->numch!=3 && p->numch!=4)
     error(EXIT_FAILURE, 0, "the number of input color channels has to be "
           "1 (for non image data, grayscale or only K channel in CMYK), "
-          "3 (for RGB) and 4 (for CMYK). You have given %lu color channels. "
+          "3 (for RGB) and 4 (for CMYK). You have given %zu color channels. "
           "Note that some file formats (for example JPEG) can contain more "
           "than one color channel", p->numch);
 
@@ -440,7 +440,7 @@ sanitycheck(struct converttparams *p)
       if(i!=p->numch)
         {
           for(i=0;i<p->numch;++i)
-            fprintf(stderr, "Channel %lu is %lu x %lu pixels.\n", i,
+            fprintf(stderr, "Channel %zu is %zu x %zu pixels.\n", i,
                     p->s1[i], p->s0[i]);
           error(EXIT_FAILURE, 0, "the input color channels have different "
                 "sizes");
@@ -454,8 +454,8 @@ sanitycheck(struct converttparams *p)
         errno=0;
         p->ch[i]=calloc(p->s0[0]*p->s1[0], sizeof *p->ch[i]);
         if(p->ch[i]==NULL)
-          error(EXIT_FAILURE, errno, "allocating %lu bytes for the blank "
-                "channel %lu", p->s0[0]*p->s1[0]*sizeof *p->ch[i], i);
+          error(EXIT_FAILURE, errno, "allocating %zu bytes for the blank "
+                "channel %zu", p->s0[0]*p->s1[0]*sizeof *p->ch[i], i);
       }
 
   /* The output file name. First find the first non-blank file name: */
@@ -511,7 +511,7 @@ sanitycheck(struct converttparams *p)
           if(p->numch>1)
             error(EXIT_FAILURE, 0, "text output (`--output=%s`) can only be "
                   "completed with one input color channel. You have given "
-                  "%lu. Note that some formats (for example JPEG) can have "
+                  "%zu. Note that some formats (for example JPEG) can have "
                   "more than one color channel in each file. You can first "
                   "convert the file to FITS, then convert the desired "
                   "channel to text by specifying the HDU",
diff --git a/bin/convolve/convolve.c b/bin/convolve/convolve.c
index 0125667..e372239 100644
--- a/bin/convolve/convolve.c
+++ b/bin/convolve/convolve.c
@@ -58,7 +58,7 @@ complextoreal(double *c, size_t size, int action, double 
**output)
   errno=0;
   *output=out=malloc(size*sizeof *out);
   if(out==NULL)
-    error(EXIT_FAILURE, errno, "%lu bytes for out in complextoreal",
+    error(EXIT_FAILURE, errno, "%zu bytes for out in complextoreal",
           size*sizeof *out);
 
   of=(o=out)+size;
@@ -205,7 +205,7 @@ makepaddedcomplex(struct convolveparams *p)
   errno=0;
   pimg=p->pimg=malloc(2*ps0*ps1*sizeof *pimg);
   if(pimg==NULL)
-    error(EXIT_FAILURE, errno, "%lu bytes for pimg",
+    error(EXIT_FAILURE, errno, "%zu bytes for pimg",
           2*ps0*ps1*sizeof *pimg);
   for(i=0;i<ps0;++i)
     {
@@ -223,7 +223,7 @@ makepaddedcomplex(struct convolveparams *p)
   errno=0;
   pker=p->pker=malloc(2*ps0*ps1*sizeof *pker);
   if(pker==NULL)
-    error(EXIT_FAILURE, errno, "%lu bytes for pker",
+    error(EXIT_FAILURE, errno, "%zu bytes for pker",
           2*ps0*ps1*sizeof *pker);
   for(i=0;i<ps0;++i)
     {
@@ -310,7 +310,7 @@ fftinitializer(struct convolveparams *p, struct 
fftonthreadparams **outfp)
   errno=0;
   *outfp=fp=malloc(p->cp.numthreads*sizeof *fp);
   if(fp==NULL)
-    error(EXIT_FAILURE, errno, "%lu bytes in forward2dfft for fp",
+    error(EXIT_FAILURE, errno, "%zu bytes in forward2dfft for fp",
           p->cp.numthreads*sizeof *fp);
 
   /* Initialize the gsl_fft_wavetable structures (these are thread
@@ -375,7 +375,7 @@ correctdeconvolve(struct convolveparams *p, double 
**spatial)
   errno=0;
   n=malloc(ps0*ps1*sizeof *n);
   if(n==NULL)
-    error(EXIT_FAILURE, errno, "%lu bytes for n in correctdeconvolve "
+    error(EXIT_FAILURE, errno, "%zu bytes for n in correctdeconvolve "
           "(convolve.c). ", ps0*ps1*sizeof *n);
 
 
@@ -406,7 +406,7 @@ correctdeconvolve(struct convolveparams *p, double 
**spatial)
           r=sqrt( (ii-ci)*(ii-ci) + (jj-cj)*(jj-cj) );
           sum += n[ii*ps1+jj] = r < p->makekernel ? s[i*ps1+j] : 0;
 
-          /*printf("(%lu, %lu) --> (%lu, %lu)\n", i, j, ii, jj);*/
+          /*printf("(%zu, %zu) --> (%zu, %zu)\n", i, j, ii, jj);*/
         }
     }
 
@@ -570,7 +570,7 @@ twodimensionfft(struct convolveparams *p, struct 
fftonthreadparams *fp,
             fp[i].forward1backwardn1=forward1backwardn1;
             err=pthread_create(&t, &attr, onedimensionfft, &fp[i]);
             if(err)
-              error(EXIT_FAILURE, 0, "can't create thread %lu for rows",
+              error(EXIT_FAILURE, 0, "can't create thread %zu for rows",
                     i);
           }
 
@@ -610,7 +610,7 @@ twodimensionfft(struct convolveparams *p, struct 
fftonthreadparams *fp,
             err=pthread_create(&t, &attr, onedimensionfft, &fp[i]);
             if(err)
               error(EXIT_FAILURE, 0,
-                    "can't create thread %lu for columns", i);
+                    "can't create thread %zu for columns", i);
           }
       pthread_barrier_wait(&b);
       pthread_attr_destroy(&attr);
diff --git a/bin/convolve/ui.c b/bin/convolve/ui.c
index 5ea0e90..6b57113 100644
--- a/bin/convolve/ui.c
+++ b/bin/convolve/ui.c
@@ -86,7 +86,7 @@ readconfig(char *filename, struct convolveparams *p)
   errno=0;
   line=malloc(len*sizeof *line);
   if(line==NULL)
-    error(EXIT_FAILURE, errno, "ui.c: %lu bytes in readdefaults",
+    error(EXIT_FAILURE, errno, "ui.c: %zu bytes in readdefaults",
           len * sizeof *line);
 
   /* Read the tokens in the file:  */
@@ -253,11 +253,11 @@ printvalues(FILE *fp, struct convolveparams *p)
 
   fprintf(fp, "\n# Mesh grid:\n");
   if(up->meshsizeset)
-    fprintf(fp, CONF_SHOWFMT"%lu\n", "meshsize", mp->meshsize);
+    fprintf(fp, CONF_SHOWFMT"%zu\n", "meshsize", mp->meshsize);
   if(up->nch1set)
-    fprintf(fp, CONF_SHOWFMT"%lu\n", "nch1", mp->nch1);
+    fprintf(fp, CONF_SHOWFMT"%zu\n", "nch1", mp->nch1);
   if(up->nch2set)
-    fprintf(fp, CONF_SHOWFMT"%lu\n", "nch2", mp->nch2);
+    fprintf(fp, CONF_SHOWFMT"%zu\n", "nch2", mp->nch2);
   if(up->lastmeshfracset)
     fprintf(fp, CONF_SHOWFMT"%.3f\n", "lastmeshfrac", mp->lastmeshfrac);
   if(up->fullconvolutionset)
@@ -459,9 +459,9 @@ preparearrays(struct convolveparams *p)
         error(EXIT_FAILURE, 0, "with the `--makekernel' (`-m') option, "
               "the input image and the image specified with the kernel "
               "option should have the same size. The lower resolution "
-              "input image (%s) has %lux%lu pixels while the higher "
+              "input image (%s) has %zux%zu pixels while the higher "
               "resolution image (%s) specified with the kernel option has "
-              "%lux%lu pixels", up->inputname, p->is1, p->is0,
+              "%zux%zu pixels", up->inputname, p->is1, p->is0,
               up->kernelname, p->ks1, p->ks0);
 
       /* Divide both images by their sum so their lowest frequency
@@ -492,7 +492,7 @@ preparearrays(struct convolveparams *p)
           if(p->ks0%2==0 || p->ks1%2==0)
             error(EXIT_FAILURE, 0, "the kernel image has to have an odd "
                   "number of pixels on both sides (there has to be on pixel "
-                  "in the center). %s (hdu: %s) is %lu by %lu",
+                  "in the center). %s (hdu: %s) is %zu by %zu",
                   p->up.kernelname, p->up.khdu, p->ks1, p->ks0);
 
           /* Convert all the NaN pixels to zero if the kernel contains
@@ -586,7 +586,7 @@ setparams(int argc, char *argv[], struct convolveparams *p)
   if(cp->verb)
     {
       printf(SPACK_NAME" started on %s", ctime(&p->rawtime));
-      printf("  - Using %lu CPU threads.\n", p->cp.numthreads);
+      printf("  - Using %zu CPU threads.\n", p->cp.numthreads);
       printf("  - Input: %s (hdu: %s)\n", p->up.inputname, p->cp.hdu);
       if(p->up.maskname)
         printf("  - Mask: %s (hdu: %s)\n", p->up.maskname, p->up.mhdu);
diff --git a/bin/cosmiccal/ui.c b/bin/cosmiccal/ui.c
index 98f015e..b7e7bb7 100644
--- a/bin/cosmiccal/ui.c
+++ b/bin/cosmiccal/ui.c
@@ -90,7 +90,7 @@ readconfig(char *filename, struct cosmiccalparams *p)
   errno=0;
   line=malloc(len*sizeof *line);
   if(line==NULL)
-    error(EXIT_FAILURE, errno, "ui.c: %lu bytes in readdefaults",
+    error(EXIT_FAILURE, errno, "ui.c: %zu bytes in readdefaults",
           len * sizeof *line);
 
   /* Read the tokens in the file:  */
diff --git a/bin/header/ui.c b/bin/header/ui.c
index d0bec79..65706bf 100644
--- a/bin/header/ui.c
+++ b/bin/header/ui.c
@@ -88,7 +88,7 @@ readconfig(char *filename, struct headerparams *p)
   errno=0;
   line=malloc(len*sizeof *line);
   if(line==NULL)
-    error(EXIT_FAILURE, errno, "ui.c: %lu bytes in readdefaults",
+    error(EXIT_FAILURE, errno, "ui.c: %zu bytes in readdefaults",
           len * sizeof *line);
 
   /* Read the tokens in the file:  */
@@ -352,7 +352,7 @@ fillfitsheaderll(struct gal_linkedlist_stll *input,
           errno=0;
           fvalue=lp=malloc(sizeof *lp);
           if(lp==NULL)
-            error(EXIT_FAILURE, errno, "%lu bytes for long integer",
+            error(EXIT_FAILURE, errno, "%zu bytes for long integer",
                   sizeof *lp);
           *lp=l;
         }
@@ -367,7 +367,7 @@ fillfitsheaderll(struct gal_linkedlist_stll *input,
               errno=0;
               fvalue=dp=malloc(sizeof *dp);
               if(dp==NULL)
-                error(EXIT_FAILURE, errno, "%lu bytes for double",
+                error(EXIT_FAILURE, errno, "%zu bytes for double",
                       sizeof *dp);
               *dp=d;
             }
@@ -398,7 +398,7 @@ preparearrays(struct headerparams *p)
   len=strlen(p->up.inputname)+strlen(p->cp.hdu)+4;
   ffname=malloc(len*sizeof *ffname);
   if(ffname==NULL)
-    error(EXIT_FAILURE, errno, "%lu characters", len);
+    error(EXIT_FAILURE, errno, "%zu characters", len);
   sprintf(ffname, "%s[%s#]", p->up.inputname, p->cp.hdu);
 
   /* Open the FITS file: */
diff --git a/bin/imgcrop/crop.c b/bin/imgcrop/crop.c
index baaa1d8..3bdebf4 100644
--- a/bin/imgcrop/crop.c
+++ b/bin/imgcrop/crop.c
@@ -214,7 +214,7 @@ polygonparser(struct imgcropparams *p)
           read[dim]=strtod(pt, &tailptr);
 
           /* Check if there actually was a number.
-          printf("\n\n------\n%lu: %f (%s)\n", dim, read[dim], tailptr);
+          printf("\n\n------\n%zu: %f (%s)\n", dim, read[dim], tailptr);
           */
 
           /* Make sure if a number was read at all? */
@@ -305,11 +305,11 @@ polygonmask(struct cropparams *crp, void *array, long 
*fpixel_i,
      anti-clickwise manner.) */
   errno=0; ipolygon=malloc(2*nvertices*sizeof *ipolygon);
   if(ipolygon==NULL)
-    error(EXIT_FAILURE, errno, "%lu bytes for ipolygon in polygonmask "
+    error(EXIT_FAILURE, errno, "%zu bytes for ipolygon in polygonmask "
           "(crop.c)", 2*nvertices*sizeof *ipolygon);
   errno=0; ordinds=malloc(nvertices*sizeof *ordinds);
   if(ordinds==NULL)
-    error(EXIT_FAILURE, errno, "%lu bytes for ordinds in polygonmask "
+    error(EXIT_FAILURE, errno, "%zu bytes for ordinds in polygonmask "
           "(crop.c)", nvertices*sizeof *ordinds);
 
 
@@ -470,9 +470,9 @@ cropname(struct cropparams *crp)
       errno=0;
       log->name=malloc(crp->outlen);
       if(log->name==NULL)
-        error(EXIT_FAILURE, errno, "imgmode.c, %lu bytes on "
+        error(EXIT_FAILURE, errno, "imgmode.c, %zu bytes on "
               "imgcroponthreads", crp->outlen);
-      sprintf(log->name, "%s%lu%s", cp->output, crp->outindex+1,
+      sprintf(log->name, "%s%zu%s", cp->output, crp->outindex+1,
               p->suffix);
       gal_checkset_check_remove_file(log->name, cp->dontdelete);
     }
@@ -752,7 +752,7 @@ onecrop(struct cropparams *crp)
       /* A section has been added to the cropped image from this input
          image, so increment crp->imgcount and save the information of
          this image. */
-      sprintf(basename, "ICF%lu", ++p->log[crp->outindex].numimg);
+      sprintf(basename, "ICF%zu", ++p->log[crp->outindex].numimg);
       gal_fits_file_name_in_keywords(basename, img->name, &headers);
       sprintf(regionkey, "%sPIX", basename);
       sprintf(region, "%ld:%ld,%ld:%ld", fpixel_i[0], lpixel_i[0]+1,
@@ -954,25 +954,25 @@ printlog(struct imgcropparams *p)
               "# Column numbers below start from zero.\n"
               "# 0: Output file name.\n"
               "# 1: Number of images used in this cropped image.\n"
-              "# 2: Are the central %lu pixels filled? (1: yes, 0: no)\n",
+              "# 2: Are the central %zu pixels filled? (1: yes, 0: no)\n",
               p->checkcenter);
 
       /* Then print each output's information. */
       for(i=0;log[i].name;++i)
-        fprintf(logfile, "%s     %-8lu%-2d\n", log[i].name,
+        fprintf(logfile, "%s     %-8zu%-2d\n", log[i].name,
                 log[i].numimg, log[i].centerfilled);
 
       /* Report Summary: */
       if(p->cp.verb && p->up.catset)
         {
-          sprintf(msg, "%lu images created.", numfiles);
+          sprintf(msg, "%zu images created.", numfiles);
           gal_timing_report(NULL, msg, 1);
-          sprintf(msg, "%lu filled in the center.",
+          sprintf(msg, "%zu filled in the center.",
                   numcentfilled);
           gal_timing_report(NULL, msg, 1);
           if(numstitched)
             {
-              sprintf(msg, "%lu used more than one input.",
+              sprintf(msg, "%zu used more than one input.",
                       numstitched);
               gal_timing_report(NULL, msg, 1);
             }
diff --git a/bin/imgcrop/imgcrop.c b/bin/imgcrop/imgcrop.c
index e0d4c23..ea358a8 100644
--- a/bin/imgcrop/imgcrop.c
+++ b/bin/imgcrop/imgcrop.c
@@ -60,11 +60,11 @@ reportcrop(struct imgcroplog *log)
 
   /* Define the output string based on the length of the output file. */
   if ( outnamelen > FILENAME_BUFFER_IN_VERB )
-    sprintf(msg, "...%s %lu %d",
+    sprintf(msg, "...%s %zu %d",
             &log->name[ outnamelen - FILENAME_BUFFER_IN_VERB + 3 ],
             log->numimg, log->centerfilled);
   else
-    sprintf(msg, "%-" MACROSTR(FILENAME_BUFFER_IN_VERB) "s %lu %d",
+    sprintf(msg, "%-" MACROSTR(FILENAME_BUFFER_IN_VERB) "s %zu %d",
             log->name, log->numimg, log->centerfilled);
   gal_timing_report(NULL, msg, 2);
 }
@@ -292,7 +292,7 @@ imgcrop(struct imgcropparams *p)
   crp=malloc(nt*sizeof *crp);
   if(crp==NULL)
     error(EXIT_FAILURE, errno,
-          "%lu bytes in imgcrop (imgcrop.c) for crp", nt*sizeof *crp);
+          "%zu bytes in imgcrop (imgcrop.c) for crp", nt*sizeof *crp);
 
 
   /* Get the length of the output, no reasonable integer can have more
@@ -336,7 +336,7 @@ imgcrop(struct imgcropparams *p)
             crp[i].indexs=&indexs[i*thrdcols];
             err=pthread_create(&t, &attr, modefunction, &crp[i]);
             if(err)
-              error(EXIT_FAILURE, 0, "can't create thread %lu", i);
+              error(EXIT_FAILURE, 0, "can't create thread %zu", i);
           }
 
       /* Wait for all threads to finish and free the spaces. */
diff --git a/bin/imgcrop/ui.c b/bin/imgcrop/ui.c
index 3d2098f..5379942 100644
--- a/bin/imgcrop/ui.c
+++ b/bin/imgcrop/ui.c
@@ -91,7 +91,7 @@ readconfig(char *filename, struct imgcropparams *p)
   errno=0;
   line=malloc(len*sizeof *line);
   if(line==NULL)
-    error(EXIT_FAILURE, errno, "ui.c: %lu bytes in readdefaults",
+    error(EXIT_FAILURE, errno, "ui.c: %zu bytes in readdefaults",
           len * sizeof *line);
 
   /* Read the tokens in the file:  */
@@ -255,7 +255,7 @@ printvalues(FILE *fp, struct imgcropparams *p)
 
   fprintf(fp, "\n# Output parameters:\n");
   if(up->checkcenterset)
-    fprintf(fp, CONF_SHOWFMT"%lu\n", "checkcenter", p->checkcenter);
+    fprintf(fp, CONF_SHOWFMT"%zu\n", "checkcenter", p->checkcenter);
   if(cp->outputset)
     fprintf(fp, CONF_SHOWFMT"%s\n", "output", cp->output);
   if(up->suffixset)
@@ -264,21 +264,21 @@ printvalues(FILE *fp, struct imgcropparams *p)
 
   fprintf(fp, "\n# Crop parameters:\n");
   if(up->xcolset)
-    fprintf(fp, CONF_SHOWFMT"%lu\n", "xcol", p->xcol);
+    fprintf(fp, CONF_SHOWFMT"%zu\n", "xcol", p->xcol);
   if(up->ycolset)
-    fprintf(fp, CONF_SHOWFMT"%lu\n", "ycol", p->ycol);
+    fprintf(fp, CONF_SHOWFMT"%zu\n", "ycol", p->ycol);
   if(up->iwidthset)
     fprintf(fp, CONF_SHOWFMT"%ld\n", "iwidth", p->iwidth[0]);
   if(up->racolset)
-    fprintf(fp, CONF_SHOWFMT"%lu\n", "racol", p->racol);
+    fprintf(fp, CONF_SHOWFMT"%zu\n", "racol", p->racol);
   if(up->deccolset)
-    fprintf(fp, CONF_SHOWFMT"%lu\n", "deccol", p->deccol);
+    fprintf(fp, CONF_SHOWFMT"%zu\n", "deccol", p->deccol);
   if(up->wwidthset)
     fprintf(fp, CONF_SHOWFMT"%.3f\n", "wwidth", p->wwidth);
   if(up->hstartwcsset)
-    fprintf(fp, CONF_SHOWFMT"%lu\n", "hstartwcs", p->hstartwcs);
+    fprintf(fp, CONF_SHOWFMT"%zu\n", "hstartwcs", p->hstartwcs);
   if(up->hendwcsset)
-    fprintf(fp, CONF_SHOWFMT"%lu\n", "hendwcs", p->hendwcs);
+    fprintf(fp, CONF_SHOWFMT"%zu\n", "hendwcs", p->hendwcs);
 
 
   /* For the operating mode, first put the macro to print the common
@@ -524,10 +524,10 @@ sanitycheck(struct imgcropparams *p)
       polygonparser(p);
       if(p->nvertices<3)
         error(EXIT_FAILURE, 0, "a polygon has to have 3 or more vertices, "
-              "you have only given %lu (%s)", p->nvertices, p->up.polygon);
+              "you have only given %zu (%s)", p->nvertices, p->up.polygon);
       if(p->outpolygon && p->numimg>1)
         error(EXIT_FAILURE, 0, "currently in WCS mode, outpolygon can only "
-              "be set to zero when there is one image, you have given %lu "
+              "be set to zero when there is one image, you have given %zu "
               "images. For multiple images the region will be very large. "
               "It is best if you first crop out the larger region you want "
               "into one image, then mask the polygon", p->numimg);
@@ -544,7 +544,7 @@ sanitycheck(struct imgcropparams *p)
   if(cp->numthreads>1 && fits_is_reentrant()==0)
     error(EXIT_FAILURE, 0, "CFITSIO was not configured with the "
           "`--enable-reentrant` option but you have asked to operate "
-          "on %lu threads. Please configure, make and install CFITSIO "
+          "on %zu threads. Please configure, make and install CFITSIO "
           "again with this flag to use multiple threads, run `info %s "
           "CFITSIO` for more information. Alternatively you can set "
           "the number of threads to 1 by adding the `--numthreads=1` "
@@ -600,7 +600,7 @@ preparearrays(struct imgcropparams *p)
   size=p->numimg*sizeof *p->imgs;
   p->imgs=malloc(size);
   if(p->imgs==NULL)
-    error(EXIT_FAILURE, errno, "ui.c: %lu bytes for p->imgs", size);
+    error(EXIT_FAILURE, errno, "ui.c: %zu bytes for p->imgs", size);
 
   for(i=p->numimg-1;i>=0;--i)
     {
@@ -659,13 +659,13 @@ preparearrays(struct imgcropparams *p)
   errno=0;
   p->log=calloc(num+1, sizeof *p->log);
   if(p->log==NULL)
-    error(EXIT_FAILURE, errno, "ui.c: %lu bytes for p->log",
+    error(EXIT_FAILURE, errno, "ui.c: %zu bytes for p->log",
           num+1 * sizeof *p->log);
 
   /* Report timing: */
   if(p->cp.verb)
     {
-      sprintf(msg, "Read metadata of %lu images.", p->numimg);
+      sprintf(msg, "Read metadata of %zu images.", p->numimg);
       gal_timing_report(&t1, msg, 1);
     }
 }
diff --git a/bin/imgcrop/wcsmode.c b/bin/imgcrop/wcsmode.c
index 6d5132a..6d91135 100644
--- a/bin/imgcrop/wcsmode.c
+++ b/bin/imgcrop/wcsmode.c
@@ -286,7 +286,7 @@ fillcrpipolygon(struct cropparams *crp)
   errno=0;
   crp->ipolygon=malloc(2*p->nvertices*sizeof *crp->ipolygon);
   if(crp->ipolygon==NULL)
-    error(EXIT_FAILURE, errno, "%lu bytes for crpp->ipolygon in "
+    error(EXIT_FAILURE, errno, "%zu bytes for crpp->ipolygon in "
           "onecrop (crop.c)",
           2*p->nvertices*sizeof *crp->ipolygon);
 
diff --git a/bin/imgstat/imgstat.c b/bin/imgstat/imgstat.c
index 894be11..afb53ba 100644
--- a/bin/imgstat/imgstat.c
+++ b/bin/imgstat/imgstat.c
@@ -289,7 +289,7 @@ imgstat(struct imgstatparams *p)
                                            &med, &std, 1);
       if(r==0)
         printf("   #### Could not converge\n");
-      printf("   - %.2f sigma-clipping %lu times:\n",
+      printf("   - %.2f sigma-clipping %zu times:\n",
              p->sigclipmultip, p->sigclipnum);
       gal_statistics_sigma_clip_certain_num(p->sorted, 1, p->size,
                                             p->sigclipmultip, p->sigclipnum,
diff --git a/bin/imgstat/main.h b/bin/imgstat/main.h
index 875afca..3233b83 100644
--- a/bin/imgstat/main.h
+++ b/bin/imgstat/main.h
@@ -36,7 +36,7 @@ along with Gnuastro. If not, see 
<http://www.gnu.org/licenses/>.
 #define PRINTINT  "%.0f\n"
 #define STRVAL    "   -- %-45s%s\n"
 #define FNAMEVAL  "   -- %-45s%f\n"
-#define SNAMEVAL  "   -- %-45s%lu\n"
+#define SNAMEVAL  "   -- %-45s%zu\n"
 #define ASCIIHISTNUMBINS    60
 #define ASCIIHISTHEIGHT     10
 #define HISTSTRING     "Histogram"
diff --git a/bin/imgstat/ui.c b/bin/imgstat/ui.c
index 5fe7b88..c6c3f81 100644
--- a/bin/imgstat/ui.c
+++ b/bin/imgstat/ui.c
@@ -92,7 +92,7 @@ readconfig(char *filename, struct imgstatparams *p)
   errno=0;
   line=malloc(len*sizeof *line);
   if(line==NULL)
-    error(EXIT_FAILURE, errno, "ui.c: %lu bytes in readdefaults",
+    error(EXIT_FAILURE, errno, "ui.c: %zu bytes in readdefaults",
           len * sizeof *line);
 
   /* Read the tokens in the file:  */
@@ -277,7 +277,7 @@ printvalues(FILE *fp, struct imgstatparams *p)
   /* Histogram: */
   fprintf(fp, "\n# Histogram:\n");
   if(up->histnumbinsset)
-    fprintf(fp, CONF_SHOWFMT"%lu\n", "histnumbins", p->histnumbins);
+    fprintf(fp, CONF_SHOWFMT"%zu\n", "histnumbins", p->histnumbins);
   if(up->histminset)
     fprintf(fp, CONF_SHOWFMT"%.5f\n", "histmin", p->histmin);
   if(up->histmaxset)
@@ -288,7 +288,7 @@ printvalues(FILE *fp, struct imgstatparams *p)
   /* Cumulative frequency plot: */
   fprintf(fp, "\n# Cumulative frequency plot:\n");
   if(up->cfpnumset)
-    fprintf(fp, CONF_SHOWFMT"%lu\n", "cfpnum", p->cfpnum);
+    fprintf(fp, CONF_SHOWFMT"%zu\n", "cfpnum", p->cfpnum);
   if(up->cfpminset)
     fprintf(fp, CONF_SHOWFMT"%.5f\n", "cfpmin", p->cfpmin);
   if(up->cfpmaxset)
@@ -303,7 +303,7 @@ printvalues(FILE *fp, struct imgstatparams *p)
     fprintf(fp, CONF_SHOWFMT"%.3f\n", "sigcliptolerance",
             p->sigcliptolerance);
   if(up->sigclipnumset)
-    fprintf(fp, CONF_SHOWFMT"%lu\n", "sigclipnum", p->sigclipnum);
+    fprintf(fp, CONF_SHOWFMT"%zu\n", "sigclipnum", p->sigclipnum);
 
 
   /* For the operating mode, first put the macro to print the common
diff --git a/bin/imgwarp/imgwarp.c b/bin/imgwarp/imgwarp.c
index 7be0003..1207f58 100644
--- a/bin/imgwarp/imgwarp.c
+++ b/bin/imgwarp/imgwarp.c
@@ -163,7 +163,7 @@ imgwarponthread(void *inparam)
       /* For a check:
       if(ind==9999)
         {
-          printf("\n\n\nind: %lu: (%lu, %lu):\n",
+          printf("\n\n\nind: %zu: (%zu, %zu):\n",
                  ind, ind%os1+1, ind/os1+1);
           for(j=0;j<4;++j)
             printf("(%.3f, %.3f) --> (%.3f, %.3f)\n",
@@ -216,7 +216,7 @@ imgwarponthread(void *inparam)
               /* For a polygon check:
               if(ind==9999)
                 {
-                  printf("%lu -- (%ld, %ld):\n", ind, x, y);
+                  printf("%zu -- (%zd, %zd):\n", ind, x, y);
                   printf("icrn:\n");
                   for(j=0;j<4;++j)
                     printf("\t%.3f, %.3f\n", icrn[j*2], icrn[j*2+1]);
@@ -226,7 +226,7 @@ imgwarponthread(void *inparam)
                   printf("ccrn:\n");
                   for(j=0;j<numcrn;++j)
                     printf("\t%.3f, %.3f\n", ccrn[j*2], ccrn[j*2+1]);
-                  printf("[%lu]: %.3f of [%ld, %ld]: %f\n", ind,
+                  printf("[%zu]: %.3f of [%ld, %ld]: %f\n", ind,
                          gal_polygon_area(ccrn, numcrn), x, y,
                          input[(y-1)*is1+x-1]);
                 }
@@ -234,7 +234,7 @@ imgwarponthread(void *inparam)
 
               /* For a simple pixel value check:
               if(ind==97387)
-                printf("%f --> (%lu) %f\n",
+                printf("%f --> (%zu) %f\n",
                        v*gal_polygon_area(ccrn, numcrn),
                        numinput, output[ind]);
               */
@@ -248,7 +248,7 @@ imgwarponthread(void *inparam)
       if(numinput && nanarea!=0.0f)
         {
           /* For a check:
-          printf("%lu: %f/%f --> %f\n", ind, nanarea, p->opixarea,
+          printf("%zu: %f/%f --> %f\n", ind, nanarea, p->opixarea,
                  nanarea/p->opixarea);
           */
 
@@ -350,7 +350,7 @@ imgwarppreparations(struct imgwarpparams *p)
   p->outfpixval[1]=nearestint_halfhigher(ymin);
   /* For a check:
   printf("Wrapped:\n");
-  printf("onaxes: (%lu, %lu)\n", p->onaxes[0], p->onaxes[1]);
+  printf("onaxes: (%zu, %zu)\n", p->onaxes[0], p->onaxes[1]);
   printf("outfpixval=(%.4f, %.4f)\n", p->outfpixval[0], p->outfpixval[1]);
   */
 
@@ -361,7 +361,7 @@ imgwarppreparations(struct imgwarpparams *p)
   size=p->onaxes[0]*p->onaxes[1];
   p->output=malloc(size*sizeof *p->output);
   if(p->output==NULL)
-    error(EXIT_FAILURE, errno, "%lu bytes for the output array",
+    error(EXIT_FAILURE, errno, "%zu bytes for the output array",
           size*sizeof *p->output);
 
 
@@ -471,7 +471,7 @@ correctwcssaveoutput(struct imgwarpparams *p)
   gal_fits_file_name_in_keywords("INF", p->up.inputname, &headers);
   for(i=0;i<9;++i)
     {
-      sprintf(&keyword[i*FLEN_KEYWORD], "WMTX%lu_%lu", i/3+1, i%3+1);
+      sprintf(&keyword[i*FLEN_KEYWORD], "WMTX%zu_%zu", i/3+1, i%3+1);
       gal_fits_add_to_key_ll_end(&headers, TDOUBLE,
                                  &keyword[i*FLEN_KEYWORD], 0,
                                  &p->matrix[i], 0, "Warp matrix "
@@ -539,7 +539,7 @@ imgwarp(struct imgwarpparams *p)
   errno=0;
   iwp=malloc(nt*sizeof *iwp);
   if(iwp==NULL)
-    error(EXIT_FAILURE, errno, "%lu bytes in imgwarp "
+    error(EXIT_FAILURE, errno, "%zu bytes in imgwarp "
           "(imgwarp.c) for iwp", nt*sizeof *iwp);
 
 
@@ -578,7 +578,7 @@ imgwarp(struct imgwarpparams *p)
             iwp[i].indexs=&indexs[i*thrdcols];
             err=pthread_create(&t, &attr, imgwarponthread, &iwp[i]);
             if(err)
-              error(EXIT_FAILURE, 0, "can't create thread %lu", i);
+              error(EXIT_FAILURE, 0, "can't create thread %zu", i);
           }
 
       /* Wait for all threads to finish and free the spaces. */
diff --git a/bin/imgwarp/ui.c b/bin/imgwarp/ui.c
index f43d616..865fc98 100644
--- a/bin/imgwarp/ui.c
+++ b/bin/imgwarp/ui.c
@@ -89,7 +89,7 @@ readconfig(char *filename, struct imgwarpparams *p)
   errno=0;
   line=malloc(len*sizeof *line);
   if(line==NULL)
-    error(EXIT_FAILURE, errno, "ui.c: %lu bytes in readdefaults",
+    error(EXIT_FAILURE, errno, "ui.c: %zu bytes in readdefaults",
           len * sizeof *line);
 
   /* Read the tokens in the file:  */
@@ -193,9 +193,9 @@ printvalues(FILE *fp, struct imgwarpparams *p)
   if(cp->hduset)
     GAL_CHECKSET_PRINT_STRING_MAYBE_WITH_SPACE("hdu", cp->hdu);
   if(up->hstartwcsset)
-    fprintf(fp, CONF_SHOWFMT"%lu\n", "hstartwcs", p->hstartwcs);
+    fprintf(fp, CONF_SHOWFMT"%zu\n", "hstartwcs", p->hstartwcs);
   if(up->hendwcsset)
-    fprintf(fp, CONF_SHOWFMT"%lu\n", "hendwcs", p->hendwcs);
+    fprintf(fp, CONF_SHOWFMT"%zu\n", "hendwcs", p->hendwcs);
 
   fprintf(fp, "\n# Output parameters:\n");
   if(up->matrixstringset)
@@ -275,7 +275,7 @@ readmatrixoption(struct imgwarpparams *p)
   errno=0;
   p->matrix=malloc(9*sizeof *p->matrix);
   if(p->matrix==NULL)
-    error(EXIT_FAILURE, errno, "%lu bytes for temporary array to keep "
+    error(EXIT_FAILURE, errno, "%zu bytes for temporary array to keep "
           "the matrix option", 9*sizeof *p->matrix);
 
   /* Go over the string and set the values. */
@@ -296,7 +296,7 @@ readmatrixoption(struct imgwarpparams *p)
                   "could not be read as a number", t);
           t=tailptr;
           if(counter>9)       /* Note that it was ++'d! */
-            error(EXIT_FAILURE, 0, "there are %lu elements in `%s', there "
+            error(EXIT_FAILURE, 0, "there are %zu elements in `%s', there "
                   "should be 4 or 9", counter, p->up.matrixstring);
           /*printf("%f, %s\n", p->matrix[counter-1], t);*/
         }
@@ -308,7 +308,7 @@ readmatrixoption(struct imgwarpparams *p)
   else if (counter==9)
     p->ms1=p->ms0=3;
   else
-    error(EXIT_FAILURE, 0, "there are %lu numbers in the string `%s'! "
+    error(EXIT_FAILURE, 0, "there are %zu numbers in the string `%s'! "
           "It should contain 4 or 9 numbers (for a 2 by 2 or 3 by 3 "
           "matrix)", counter, p->up.matrixstring);
 }
@@ -353,7 +353,7 @@ makealignmatrix(struct imgwarpparams *p)
   errno=0;
   p->matrix=malloc(4*sizeof *p->matrix);
   if(p->matrix==NULL)
-    error(EXIT_FAILURE, errno, "%lu bytes for p->matrix in makealignmatrix",
+    error(EXIT_FAILURE, errno, "%zu bytes for p->matrix in makealignmatrix",
           4*sizeof *p->matrix);
   p->ms0=p->ms1=2;
 
@@ -428,7 +428,7 @@ makebasicmatrix(struct imgwarpparams *p)
   errno=0;
   p->matrix=malloc(4*sizeof *p->matrix);
   if(p->matrix==NULL)
-    error(EXIT_FAILURE, errno, "%lu bytes for p->matrix in makerotationmatrix",
+    error(EXIT_FAILURE, errno, "%zu bytes for p->matrix in makerotationmatrix",
           4*sizeof *p->matrix);
   p->ms0=p->ms1=2;
 
@@ -503,7 +503,7 @@ preparematrix(struct imgwarpparams *p)
       errno=0;
       tmp=malloc(9*sizeof *tmp);
       if(tmp==NULL)
-        error(EXIT_FAILURE, errno, "%lu bytes for 3 by 3 matrix",
+        error(EXIT_FAILURE, errno, "%zu bytes for 3 by 3 matrix",
               9*sizeof *tmp);
 
       /* Put the four identical elements in place. */
@@ -542,7 +542,7 @@ preparematrix(struct imgwarpparams *p)
     }
   else if (p->ms0!=3 || p->ms1!=3)
     error(EXIT_FAILURE, 0, "a bug! please contact us at %s so we can "
-          "address the problem. For some reason p->ms0=%lu and p->ms1=%lu! "
+          "address the problem. For some reason p->ms0=%zu and p->ms1=%zu! "
           "They should both have a value of 3.", PACKAGE_BUGREPORT,
           p->ms0, p->ms1);
 }
@@ -590,8 +590,8 @@ sanitycheck(struct imgwarpparams *p)
      the wrong numbers when it is read from a file. */
   if(p->up.matrixname)
      if( (p->ms0 != 2 && p->ms0 != 3) || p->ms0 != p->ms1 )
-       error(EXIT_FAILURE, 0, "the given matrix in %s has %lu rows and "
-             "%lu columns. Its size must be either 2x2 or 3x3",
+       error(EXIT_FAILURE, 0, "the given matrix in %s has %zu rows and "
+             "%zu columns. Its size must be either 2x2 or 3x3",
              p->up.matrixname, p->ms0, p->ms1);
 
   /* Check if there are any non-normal numbers in the matrix: */
@@ -661,7 +661,7 @@ preparearrays(struct imgwarpparams *p)
   errno=0;
   p->inverse=inv=malloc(9*sizeof *inv);
   if(inv==NULL)
-    error(EXIT_FAILURE, errno, "%lu bytes for the inverse array",
+    error(EXIT_FAILURE, errno, "%zu bytes for the inverse array",
           9*sizeof *inv);
   inv[0]=m[4]*m[8]-m[5]*m[7];
   inv[1]=m[2]*m[7]-m[1]*m[8];
@@ -745,7 +745,7 @@ setparams(int argc, char *argv[], struct imgwarpparams *p)
   if(cp->verb)
     {
       printf(SPACK_NAME" started on %s", ctime(&p->rawtime));
-      printf(" Using %lu CPU thread%s\n", p->cp.numthreads,
+      printf(" Using %zu CPU thread%s\n", p->cp.numthreads,
              p->cp.numthreads==1 ? "." : "s.");
       printf(" Input image: %s\n", p->up.inputname);
       printf(" matrix:"
diff --git a/bin/mkcatalog/columns.c b/bin/mkcatalog/columns.c
index 0febae3..dbbc29b 100644
--- a/bin/mkcatalog/columns.c
+++ b/bin/mkcatalog/columns.c
@@ -275,10 +275,10 @@ flxwhtimg(struct mkcatalogparams *p, size_t col)
       geoxy(p, gc);
 
       /* For a check, uncomment these two lines:
-      printf("\n\nInfocol: %lu (%s, %lu)\n", col,
+      printf("\n\nInfocol: %zu (%s, %zu)\n", col,
              p->info==p->oinfo?"Objects":"Clumps", p->num);
       Then add these two lines before and after row[col] in the loop*/
-      /*printf("%lu: %f --> ", (row-p->info)/p->icols, row[col]);*/
+      /*printf("%zu: %f --> ", (row-p->info)/p->icols, row[col]);*/
       /*printf("%f\n", row[col]);*/
 
       /* Go over all the rows and correct this column. */
@@ -354,7 +354,7 @@ setsecondmoment(struct mkcatalogparams *p, size_t col)
           default:
             error(EXIT_FAILURE, 0, "a bug! Please contact us at %s so we "
                   "can fix this. The given column in setsecondmoment's "
-                  "--CLUMP-- information table (%lu) was not recognized for "
+                  "--CLUMP-- information table (%zu) was not recognized for "
                   "correcting the second moment", PACKAGE_BUGREPORT, col);
           }
       else
@@ -408,7 +408,7 @@ setsecondmoment(struct mkcatalogparams *p, size_t col)
           default:
             error(EXIT_FAILURE, 0, "a bug! Please contact us at %s so we "
                   "can fix this. The given column in setsecondmoment's "
-                  "--OBJECT-- information table (%lu) was not recognized for "
+                  "--OBJECT-- information table (%zu) was not recognized for "
                   "correcting the second moment", PACKAGE_BUGREPORT, col);
           }
 
@@ -581,7 +581,7 @@ idcol(struct mkcatalogparams *p)
   size_t i;
 
   p->unitp=CATUNITCOUNTER;
-  sprintf(p->description, "%lu: Overall %s ID",
+  sprintf(p->description, "%zu: Overall %s ID",
           p->curcol, p->name);
 
   for(i=0;i<p->num;++i)
@@ -609,7 +609,7 @@ hostobj(struct mkcatalogparams *p, int o1c0)
   p->unitp=CATUNITCOUNTER;
   des = ( o1c0 ? "ID of object hosting this clump"
           : "ID of clump in host object" );
-  sprintf(p->description, "%lu: %s.",
+  sprintf(p->description, "%zu: %s.",
           p->curcol, des);
 
   for(i=1;i<=p->numobjects;++i)
@@ -634,7 +634,7 @@ numclumps(struct mkcatalogparams *p)
   size_t i;
 
   p->unitp=CATUNITCOUNTER;
-  sprintf(p->description, "%lu: Number of clumps in this object.",
+  sprintf(p->description, "%zu: Number of clumps in this object.",
           p->curcol);
 
   for(i=0;i<p->numobjects;++i)
@@ -685,7 +685,7 @@ area(struct mkcatalogparams *p, int cinobj, int isriver)
 
   /* Set the unit and print the header. */
   p->unitp = isriver ? CATUNITCOUNTER : CATUNITPIXAREA;
-  sprintf(p->description, "%lu: %s.", p->curcol, type);
+  sprintf(p->description, "%zu: %s.", p->curcol, type);
 
   /* Fill in the output array. */
   for(i=0;i<p->num;++i)
@@ -707,7 +707,7 @@ position(struct mkcatalogparams *p, size_t col, char 
*target,
   int wcsax = ( !strcmp(axis, MKCATRA) || !strcmp(axis, MKCATDEC) ) ? 1 : 0;
 
   /* Set the header information. */
-  sprintf(p->description, "%lu: %s %s (%s).", p->curcol, target, type, axis);
+  sprintf(p->description, "%zu: %s %s (%s).", p->curcol, target, type, axis);
 
   /* Prepare the respective column, set the units and also the
      printing accuracy if we are in RA/Dec mode (wcsax==1). */
@@ -773,7 +773,7 @@ secondordermoment(struct mkcatalogparams *p, size_t ocol, 
char *target)
     /* Output column not recognized */
     default:
       error(EXIT_FAILURE, 0, "a bug! Please contact us at %s so we can "
-            "solve this problem. The value to `ocol' (%lu) is not "
+            "solve this problem. The value to `ocol' (%zu) is not "
             "recognized in secondordermoment (first)", PACKAGE_BUGREPORT,
             ocol);
     }
@@ -821,13 +821,13 @@ secondordermoment(struct mkcatalogparams *p, size_t ocol, 
char *target)
       break;
     default:
       error(EXIT_FAILURE, 0, "a bug! Please contact us at %s so we can "
-            "solve this problem. The value to `ocol' (%lu) is not "
+            "solve this problem. The value to `ocol' (%zu) is not "
             "recognized in secondordermoment (second)", PACKAGE_BUGREPORT,
             ocol);
     }
 
   /* Set the header value */
-  sprintf(p->description, "%lu: %s %s %s.", p->curcol, target, type, name);
+  sprintf(p->description, "%zu: %s %s %s.", p->curcol, target, type, name);
 }
 
 
@@ -882,7 +882,7 @@ brightnessmag(struct mkcatalogparams *p, size_t col, char 
*target,
 
   /* Set the header information: */
   add = (col==CNoRiverBrightness) ? " sky (not river) subtracted " : " ";
-  sprintf(p->description, "%lu: %s%s%s.", p->curcol, target, add, scale);
+  sprintf(p->description, "%zu: %s%s%s.", p->curcol, target, add, scale);
 }
 
 
@@ -898,7 +898,7 @@ upperlimitcol(struct mkcatalogparams *p)
 
   /* For the comments: */
   p->unitp = CATUNITMAG;
-  sprintf(p->description, "%lu: Upper limit magnitude for this %s.",
+  sprintf(p->description, "%zu: Upper limit magnitude for this %s.",
           p->curcol, p->name);
 
 
@@ -932,7 +932,7 @@ skystd(struct mkcatalogparams *p, size_t col)
 
   /* For the comments: */
   p->unitp = CATUNITAVE;
-  sprintf(p->description, "%lu: Average %s under this %s.",
+  sprintf(p->description, "%zu: Average %s under this %s.",
           p->curcol, ( (col==OSKY || col==CSKY)
                        ? "sky" : "sky standard deviation" ),
           p->name);
@@ -977,10 +977,10 @@ sncol(struct mkcatalogparams *p, int sn0_magerr1, char 
*target)
   /* For the comments: */
   p->unitp = sn0_magerr1 ? CATUNITMAG : CATUNITRATIO;
   if(sn0_magerr1)
-    sprintf(p->description, "%lu: %s Magnitude error.", p->curcol,
+    sprintf(p->description, "%zu: %s Magnitude error.", p->curcol,
             target);
   else
-    sprintf(p->description, "%lu: %s signal to noise ratio.", p->curcol,
+    sprintf(p->description, "%zu: %s signal to noise ratio.", p->curcol,
             target);
 
   /* Calculate the signal to noise ratio. Recall that for the objects,
diff --git a/bin/mkcatalog/mkcatalog.c b/bin/mkcatalog/mkcatalog.c
index b2455e7..9d21ed6 100644
--- a/bin/mkcatalog/mkcatalog.c
+++ b/bin/mkcatalog/mkcatalog.c
@@ -215,7 +215,7 @@ clumppass(struct mkcatalogparams *p)
      order to give the row number in the clumps information table. */
   errno=0; ofcrow=malloc((p->numobjects+1)*sizeof *ofcrow);
   if(ofcrow==NULL)
-    error(EXIT_FAILURE, errno, "%lu bytes for ofcrow in seconpass "
+    error(EXIT_FAILURE, errno, "%zu bytes for ofcrow in seconpass "
           "(mkcatalog.c)", (p->numobjects+1)*sizeof *ofcrow);
 
 
@@ -436,11 +436,11 @@ makeoutput(struct mkcatalogparams *p)
       /* Allocate the integer and accuracy arrays: */
       errno=0; p->intcols=malloc(p->numcols*sizeof *p->intcols);
       if(p->intcols==NULL)
-        error(EXIT_FAILURE, errno, "%lu bytes for intcols in makeoutput "
+        error(EXIT_FAILURE, errno, "%zu bytes for intcols in makeoutput "
               "(mkcatalog.c)", p->numcols*sizeof *p->intcols);
       errno=0; p->accucols=malloc(p->numcols*sizeof *p->accucols);
       if(p->accucols==NULL)
-        error(EXIT_FAILURE, errno, "%lu bytes for accucols in makeoutput "
+        error(EXIT_FAILURE, errno, "%zu bytes for accucols in makeoutput "
               "(mkcatalog.c)", p->numcols*sizeof *p->accucols);
 
 
@@ -541,10 +541,10 @@ makeoutput(struct mkcatalogparams *p)
       /* If an upper limit was output then report its parameters: */
       if(p->obj0clump1==0 && p->up.upperlimitmagset)
         {
-          sprintf(p->line, "# "CATDESCRIPTLENGTH"%lu\n", "Number of upper "
+          sprintf(p->line, "# "CATDESCRIPTLENGTH"%zu\n", "Number of upper "
                   "limit magnitude samples", p->upnum);
           strcat(comment, p->line);
-          sprintf(p->line, "# "CATDESCRIPTLENGTH"%lu\n", "Number of threads "
+          sprintf(p->line, "# "CATDESCRIPTLENGTH"%zu\n", "Number of threads "
                   "used for upper limit magnitude",
                   p->cp.numthreads);
           strcat(comment, p->line);
@@ -552,7 +552,7 @@ makeoutput(struct mkcatalogparams *p)
                   "generator type for upper limit magnitude",
                   gsl_rng_default->name);
           strcat(comment, p->line);
-          sprintf(p->line, "# "CATDESCRIPTLENGTH"%lu\n", "Random number "
+          sprintf(p->line, "# "CATDESCRIPTLENGTH"%zu\n", "Random number "
                   "generator seed for upper limit magnitude",
                   gsl_rng_default_seed);
           strcat(comment, p->line);
@@ -736,7 +736,7 @@ makeoutput(struct mkcatalogparams *p)
 
             default:
               error(EXIT_FAILURE, 0, "a bug! Please contact us at %s so we "
-                    "can fix the problem. The value to cols[%lu] (%lu), is "
+                    "can fix the problem. The value to cols[%zu] (%zu), is "
                     "not recognized in makeoutput (mkcatalog.c)",
                     PACKAGE_BUGREPORT, p->curcol, cols[p->curcol]);
             }
diff --git a/bin/mkcatalog/ui.c b/bin/mkcatalog/ui.c
index 1658313..0c2fc5d 100644
--- a/bin/mkcatalog/ui.c
+++ b/bin/mkcatalog/ui.c
@@ -90,7 +90,7 @@ readconfig(char *filename, struct mkcatalogparams *p)
   errno=0;
   line=malloc(len*sizeof *line);
   if(line==NULL)
-    error(EXIT_FAILURE, errno, "ui.c: %lu bytes in readdefaults",
+    error(EXIT_FAILURE, errno, "ui.c: %zu bytes in readdefaults",
           len * sizeof *line);
 
   /* Read the tokens in the file:  */
@@ -702,7 +702,7 @@ printvalues(FILE *fp, struct mkcatalogparams *p)
   if(up->upmaskhduset)
     fprintf(fp, CONF_SHOWFMT"%s\n", "upmaskhdu", up->upmaskhdu);
   if(up->upnumset)
-    fprintf(fp, CONF_SHOWFMT"%lu\n", "upnum", p->upnum);
+    fprintf(fp, CONF_SHOWFMT"%zu\n", "upnum", p->upnum);
   if(up->envseedset)
     fprintf(fp, CONF_SHOWFMT"%d\n", "envseed", p->envseed);
   if(up->upsclipmultipset)
@@ -843,7 +843,7 @@ printvalues(FILE *fp, struct mkcatalogparams *p)
       default:
         error(EXIT_FAILURE, 0, "a bug! Please contact us at %s so we can "
               "fix the problem. For some reason p->allcols[%d] is given "
-              "the value %lu which is not recognized in printvalues "
+              "the value %zu which is not recognized in printvalues "
               "(ui.c)", PACKAGE_BUGREPORT, i, p->allcols[i]);
       }
 
@@ -1049,8 +1049,8 @@ checksetlong(struct mkcatalogparams *p, char *filename, 
char *hdu,
 
   /* Make sure it is the same size as the input image. */
   if(s0!=p->s0 || s1!=p->s1)
-    error(EXIT_FAILURE, 0, "%s (hdu: %s) is %lu x %lu pixels while the "
-          "%s (hdu: %s) is %lu x %lu. The images should have the same "
+    error(EXIT_FAILURE, 0, "%s (hdu: %s) is %zu x %zu pixels while the "
+          "%s (hdu: %s) is %zu x %zu. The images should have the same "
           "size", filename, hdu, s1, s0, p->up.inputname,
           p->cp.hdu, p->s1, p->s0);
 }
@@ -1079,8 +1079,8 @@ checksetfloat(struct mkcatalogparams *p, char *filename, 
char *hdu,
 
   /* Make sure it has the same size as the image. */
   if(s0!=p->s0 || s1!=p->s1)
-    error(EXIT_FAILURE, 0, "%s (hdu: %s) is %lu x %lu pixels while the "
-          "%s (hdu: %s) is %lu x %lu. The images should have the same "
+    error(EXIT_FAILURE, 0, "%s (hdu: %s) is %zu x %zu pixels while the "
+          "%s (hdu: %s) is %zu x %zu. The images should have the same "
           "size", filename, hdu, s1, s0, p->up.inputname,
           p->cp.hdu, p->s1, p->s0);
 }
@@ -1190,11 +1190,11 @@ preparearrays(struct mkcatalogparams *p)
     error(EXIT_FAILURE, 0, "no columns specified for output");
   errno=0; p->objcols=malloc(p->allncols*sizeof *p->objcols);
   if(p->objcols==NULL)
-    error(EXIT_FAILURE, errno, "%lu bytes for p->objcols in "
+    error(EXIT_FAILURE, errno, "%zu bytes for p->objcols in "
           "preprarearrays (ui.c)", p->allncols*sizeof *p->objcols);
   errno=0; p->clumpcols=malloc(p->allncols*sizeof *p->clumpcols);
   if(p->clumpcols==NULL)
-    error(EXIT_FAILURE, errno, "%lu bytes for p->clumpcols in "
+    error(EXIT_FAILURE, errno, "%zu bytes for p->clumpcols in "
           "preprarearrays (ui.c)", p->allncols*sizeof *p->clumpcols);
 
 
@@ -1349,8 +1349,8 @@ preparearrays(struct mkcatalogparams *p)
           break;
         default:
           error(EXIT_FAILURE, 0, "a bug! Please contact us at %s so we "
-                "can fix the problem. For some reason p->allcols[%lu] "
-                "is given the value %lu which is not recognized in "
+                "can fix the problem. For some reason p->allcols[%zu] "
+                "is given the value %zu which is not recognized in "
                 "preparearrays (ui.c)", PACKAGE_BUGREPORT, i,
                 p->allcols[i]);
         }
@@ -1392,7 +1392,7 @@ preparearrays(struct mkcatalogparams *p)
           errno=0;
           p->objcat=malloc(p->objncols*p->numobjects*sizeof *p->objcat);
           if(p->objcat==NULL)
-            error(EXIT_FAILURE, errno, "%lu bytes for p->objcat in "
+            error(EXIT_FAILURE, errno, "%zu bytes for p->objcat in "
                   "preprarearrays (ui.c)",
                   p->objncols*p->numobjects*sizeof *p->objcat);
         }
@@ -1403,7 +1403,7 @@ preparearrays(struct mkcatalogparams *p)
           p->clumpcat=malloc(p->clumpncols*p->numclumps
                              * sizeof *p->clumpcat);
           if(p->clumpcat==NULL)
-            error(EXIT_FAILURE, errno, "%lu bytes for p->clumpcat in "
+            error(EXIT_FAILURE, errno, "%zu bytes for p->clumpcat in "
                   "preprarearrays (ui.c)",
                   p->clumpncols*p->numclumps*sizeof *p->clumpcat);
         }
@@ -1418,11 +1418,11 @@ preparearrays(struct mkcatalogparams *p)
      zero.*/
   errno=0; p->oinfo=calloc(OCOLUMNS*(p->numobjects+1), sizeof *p->oinfo);
   if(p->oinfo==NULL)
-    error(EXIT_FAILURE, errno, "%lu bytes for p->oinfo in mkcatalog "
+    error(EXIT_FAILURE, errno, "%zu bytes for p->oinfo in mkcatalog "
           "(mkcatalog.c)", OCOLUMNS*(p->numobjects+1)*sizeof *p->oinfo);
   errno=0; p->cinfo=calloc(CCOLUMNS*(p->numclumps+1), sizeof *p->cinfo);
   if(p->cinfo==NULL)
-    error(EXIT_FAILURE, errno, "%lu bytes for p->cinfo in mkcatalog "
+    error(EXIT_FAILURE, errno, "%zu bytes for p->cinfo in mkcatalog "
           "(mkcatalog.c)", CCOLUMNS*(p->numclumps+1)*sizeof *p->cinfo);
 
   /* Set the shift values to NAN for all the objects and clumps: */
diff --git a/bin/mkcatalog/upperlimit.c b/bin/mkcatalog/upperlimit.c
index fa30ff2..862ec49 100644
--- a/bin/mkcatalog/upperlimit.c
+++ b/bin/mkcatalog/upperlimit.c
@@ -164,7 +164,7 @@ fillseginfo(struct upperlimitparams *p, long *seg)
   errno=0;
   p->box=malloc(p->numlabs * 4 * sizeof *p->box);
   if(p->box==NULL)
-    error(EXIT_FAILURE, errno, "%lu bytes for p->box",
+    error(EXIT_FAILURE, errno, "%zu bytes for p->box",
           p->numlabs * 4 * sizeof *p->box);
 
   /* Initialize the information array*/
@@ -191,7 +191,7 @@ fillseginfo(struct upperlimitparams *p, long *seg)
      start from 1, not zero.
   {
     i=0;
-    printf("%lu: (%lu, %lu) --> (%lu, %lu)\n", i+p->minlab,
+    printf("%zu: (%zu, %zu) --> (%zu, %zu)\n", i+p->minlab,
           p->box[i*4+YMINCOL]+1, p->box[i*4+XMINCOL]+1,
           p->box[i*4+YMAXCOL]+1, p->box[i*4+XMAXCOL]+1);
   }
@@ -204,7 +204,7 @@ fillseginfo(struct upperlimitparams *p, long *seg)
   errno=0;
   p->pix=malloc(p->numlabs * sizeof *p->pix);
   if(p->pix==NULL)
-    error(EXIT_FAILURE, errno, "%lu bytes for p->pix",
+    error(EXIT_FAILURE, errno, "%zu bytes for p->pix",
           p->numlabs * sizeof *p->pix);
   for(i=0; i<p->numlabs; ++i)
     {
@@ -217,7 +217,7 @@ fillseginfo(struct upperlimitparams *p, long *seg)
       asize = p->box[i*4+XWIDCOL] * p->box[i*4+YWIDCOL] * sizeof **p->pix;
       p->pix[i] = malloc(asize);
       if(p->pix[i]==NULL)
-        error(EXIT_FAILURE, errno, "%lu bytes for p->pix[i] (i=%lu)",
+        error(EXIT_FAILURE, errno, "%zu bytes for p->pix[i] (i=%zu)",
               asize, i);
 
       /* Set the array values. Any pixel that is equal to the object's
@@ -251,7 +251,7 @@ fillseginfo(struct upperlimitparams *p, long *seg)
      full list of IDs, not just those in the image. */
   p->std = malloc( (maxlab+1) * sizeof *p->std );
   if(p->std==NULL)
-    error(EXIT_FAILURE, errno, "%lu bytes for p->std (upperlimit.c)",
+    error(EXIT_FAILURE, errno, "%zu bytes for p->std (upperlimit.c)",
           (maxlab+1) * sizeof *p->std);
   ff=(f=p->std)+(maxlab+1); do *f++=NAN; while(f<ff);
 }
@@ -279,7 +279,7 @@ prepareimg(struct upperlimitparams *p, float *img, float 
*sky, long *seg,
   errno=0;
   p->img=malloc(size * sizeof *p->img);
   if(p->img==NULL)
-    error(EXIT_FAILURE, errno, "%lu bytes for p->img (upperlimit.c)",
+    error(EXIT_FAILURE, errno, "%zu bytes for p->img (upperlimit.c)",
           size * sizeof *p->img);
 
   /* Set the values. */
@@ -350,7 +350,7 @@ upperlimit_on_thread(void *inparam)
   errno=0;
   sum=malloc(p->upnum*sizeof *sum);
   if(sum==NULL)
-    error(EXIT_FAILURE, errno, "%lu bytes for sum (upperlimit.c)",
+    error(EXIT_FAILURE, errno, "%zu bytes for sum (upperlimit.c)",
           p->upnum*sizeof *sum);
 
   /* Allocate the random number generator for this thread. Note that when
@@ -396,7 +396,7 @@ upperlimit_on_thread(void *inparam)
            }
 
          /* Only use this sum if it is not a NaN. */
-          /*printf("%lu: %f\n", c, sum[c]);*/
+          /*printf("%zu: %f\n", c, sum[c]);*/
          if(!isnan(sum[c])) ++c;
        }
 
@@ -452,7 +452,7 @@ upperlimit_manager(struct upperlimitparams *p)
   errno=0;
   tp = malloc(p->numthreads*sizeof *tp);
   if( tp==NULL )
-    error(EXIT_FAILURE, errno, "%lu bytes for tp (upperlimit.c)",
+    error(EXIT_FAILURE, errno, "%zu bytes for tp (upperlimit.c)",
           p->numthreads*sizeof *tp);
 
   /* Distribute the actions into the threads: */
@@ -492,7 +492,7 @@ upperlimit_manager(struct upperlimitparams *p)
             err=pthread_create(&t, &attr, upperlimit_on_thread, &tp[i]);
             if(err)
               {
-                fprintf(stderr, "can't create thread %lu", i);
+                fprintf(stderr, "can't create thread %zu", i);
                 exit(EXIT_FAILURE);
               }
           }
@@ -558,7 +558,7 @@ upperlimit(float *img, float *sky, long *seg, long *mask, 
size_t s0,
 
   /* For a check:
   for(i=1;i<p.minlab+p.numlabs;++i)
-    printf("i=%lu: %-10.5f\n", i, p.std[i]);
+    printf("i=%zu: %-10.5f\n", i, p.std[i]);
   exit(0);
   */
 
diff --git a/bin/mknoise/ui.c b/bin/mknoise/ui.c
index d369bdb..4da2bc5 100644
--- a/bin/mknoise/ui.c
+++ b/bin/mknoise/ui.c
@@ -88,7 +88,7 @@ readconfig(char *filename, struct mknoiseparams *p)
   errno=0;
   line=malloc(len*sizeof *line);
   if(line==NULL)
-    error(EXIT_FAILURE, errno, "ui.c: %lu bytes in readdefaults",
+    error(EXIT_FAILURE, errno, "ui.c: %zu bytes in readdefaults",
           len * sizeof *line);
 
   /* Read the tokens in the file:  */
@@ -382,7 +382,7 @@ setparams(int argc, char *argv[], struct mknoiseparams *p)
       gal_timing_report(NULL, message, 1);
       if(p->envseed)
         {
-          sprintf(message, "Random number generator seed: %lu",
+          sprintf(message, "Random number generator seed: %zu",
                   gsl_rng_default_seed);
           gal_timing_report(NULL, message, 1);
         }
diff --git a/bin/mkprof/mkprof.c b/bin/mkprof/mkprof.c
index 38a09ec..4f0713a 100644
--- a/bin/mkprof/mkprof.c
+++ b/bin/mkprof/mkprof.c
@@ -77,7 +77,7 @@ builtqueue_addempty(struct builtqueue **bq)
   errno=0;
   tbq=malloc(sizeof *tbq);
   if(tbq==NULL)
-    error(EXIT_FAILURE, 0, "%lu byte element in builtqueue_addempty",
+    error(EXIT_FAILURE, 0, "%zu byte element in builtqueue_addempty",
           sizeof *tbq);
 
   /* Initialize some of the values. */
@@ -130,8 +130,8 @@ saveindividual(struct mkonthread *mkp)
   len=strlen(outdir)+NUMBERNAMESTRLEN+strlen(p->mergedimgname);
   outname=malloc(len*sizeof *outname);
   if(outname==NULL)
-    error(EXIT_FAILURE, errno, "%lu bytes for name of object in "
-          "row %lu of %s", len*sizeof *outname, ibq->id,
+    error(EXIT_FAILURE, errno, "%zu bytes for name of object in "
+          "row %zu of %s", len*sizeof *outname, ibq->id,
           p->up.catname);
 
   /* Save the correct CRPIX values: */
@@ -139,7 +139,7 @@ saveindividual(struct mkonthread *mkp)
   crpix[1] = p->crpix[1] - os*(mkp->fpixel_i[1]-1);
 
   /* Write the name and remove a similarly named file. */
-  sprintf(outname, "%s%lu_%s", outdir, ibq->id, p->basename);
+  sprintf(outname, "%s%zu_%s", outdir, ibq->id, p->basename);
   gal_checkset_check_remove_file(outname, p->cp.dontdelete);
 
   /* Write the array to file (A separately built PSF doesn't need WCS
@@ -429,7 +429,7 @@ write(struct mkprofparams *p)
       errno=0;
       out=calloc(p->naxes[0]*p->naxes[1], sizeof *out);
       if(out==NULL)
-        error(EXIT_FAILURE, 0, "%lu bytes for output image",
+        error(EXIT_FAILURE, 0, "%zu bytes for output image",
               p->naxes[0]*p->naxes[1]*sizeof *out);
     }
 
@@ -527,7 +527,7 @@ write(struct mkprofparams *p)
           jobname=malloc(100*sizeof *jobname);
           if(jobname==NULL)
             error(EXIT_FAILURE, errno, "jobname in mkprof.c");
-          sprintf(jobname, "row %lu complete, %lu left to go",
+          sprintf(jobname, "row %zu complete, %zu left to go",
                   ibq->id, cs0-complete);
           gal_timing_report(NULL, jobname, 2);
           free(jobname);
@@ -625,7 +625,7 @@ mkprof(struct mkprofparams *p)
   mkp=malloc(nt*sizeof *mkp);
   if(mkp==NULL)
     error(EXIT_FAILURE, errno,
-          "%lu bytes in mkprof (mkprof.c) for mkp", (nt-1)*sizeof *mkp);
+          "%zu bytes in mkprof (mkprof.c) for mkp", (nt-1)*sizeof *mkp);
 
   /* Distribute the different profiles for different threads. Note
      that one thread is left out for writing, while nt-1 are left
@@ -672,7 +672,7 @@ mkprof(struct mkprofparams *p)
             mkp[i].indexs=&indexs[i*thrdcols];
             err=pthread_create(&t, &attr, build, &mkp[i]);
             if(err)
-              error(EXIT_FAILURE, 0, "can't create thread %lu", i);
+              error(EXIT_FAILURE, 0, "can't create thread %zu", i);
           }
     }
 
diff --git a/bin/mkprof/oneprofile.c b/bin/mkprof/oneprofile.c
index b4ddce5..ef42c83 100644
--- a/bin/mkprof/oneprofile.c
+++ b/bin/mkprof/oneprofile.c
@@ -257,7 +257,7 @@ makepixbypix(struct mkonthread *mkp)
   errno=0;
   byt=calloc(is0*is1, sizeof *byt);
   if(byt==NULL)
-    error(EXIT_FAILURE, 0, "%lu bytes for map of object in row %lu of "
+    error(EXIT_FAILURE, 0, "%zu bytes for map of object in row %zu of "
           "data in %s", is0*is1*sizeof *byt, ibq->id,
           mkp->p->up.catname);
 
@@ -294,7 +294,7 @@ makepixbypix(struct mkonthread *mkp)
           mkp->yl=mkp->y-hp;
           mkp->yh=mkp->y+hp;
           /*
-            printf("Center (%lu, %lu). r: %.4f. x: [%.4f--%.4f], "
+            printf("Center (%zu, %zu). r: %.4f. x: [%.4f--%.4f], "
                    "y: [%.4f, %.4f]\n", p%is1+1, p/is1+1, mkp->r, mkp->xl,
                    mkp->xh, mkp->yl, mkp->yh);
           */
@@ -598,7 +598,7 @@ makeoneprofile(struct mkonthread *mkp)
   size=mkp->width[0]*mkp->width[1];
   mkp->ibq->img=calloc(size, sizeof *mkp->ibq->img);
   if(mkp->ibq->img==NULL)
-    error(EXIT_FAILURE, 0, "%lu bytes for object in row %lu of data in %s",
+    error(EXIT_FAILURE, 0, "%zu bytes for object in row %zu of data in %s",
           size*sizeof *mkp->ibq->img, mkp->ibq->id, mkp->p->up.catname);
 
 
diff --git a/bin/mkprof/ui.c b/bin/mkprof/ui.c
index ccfdb14..43ca5fe 100644
--- a/bin/mkprof/ui.c
+++ b/bin/mkprof/ui.c
@@ -91,7 +91,7 @@ readconfig(char *filename, struct mkprofparams *p)
   errno=0;
   line=malloc(len*sizeof *line);
   if(line==NULL)
-    error(EXIT_FAILURE, errno, "ui.c: %lu bytes in readdefaults",
+    error(EXIT_FAILURE, errno, "ui.c: %zu bytes in readdefaults",
           len * sizeof *line);
 
   /* Read the tokens in the file:  */
@@ -390,13 +390,13 @@ printvalues(FILE *fp, struct mkprofparams *p)
   if(cp->outputset)
     fprintf(fp, CONF_SHOWFMT"%s\n", "output", cp->output);
   if(up->naxis1set)
-    fprintf(fp, CONF_SHOWFMT"%lu\n", "naxis1", p->naxes[0]);
+    fprintf(fp, CONF_SHOWFMT"%zu\n", "naxis1", p->naxes[0]);
   if(up->naxis2set)
-    fprintf(fp, CONF_SHOWFMT"%lu\n", "naxis2", p->naxes[1]);
+    fprintf(fp, CONF_SHOWFMT"%zu\n", "naxis2", p->naxes[1]);
   if(up->inputascanvasset)
     fprintf(fp, CONF_SHOWFMT"%d\n", "inputascanvas", up->inputascanvas);
   if(up->oversampleset)
-    fprintf(fp, CONF_SHOWFMT"%lu\n", "oversample", p->oversample);
+    fprintf(fp, CONF_SHOWFMT"%zu\n", "oversample", p->oversample);
   if(up->replaceset)
     fprintf(fp, CONF_SHOWFMT"%d\n", "replace", p->replace);
   if(up->typeset)
@@ -406,7 +406,7 @@ printvalues(FILE *fp, struct mkprofparams *p)
   if(up->tunitinpset)
     fprintf(fp, CONF_SHOWFMT"%d\n", "tunitinp", p->tunitinp);
   if(up->numrandomset)
-    fprintf(fp, CONF_SHOWFMT"%lu\n", "numrandom", p->numrandom);
+    fprintf(fp, CONF_SHOWFMT"%zu\n", "numrandom", p->numrandom);
   if(up->toleranceset)
     fprintf(fp, CONF_SHOWFMT"%.2f\n", "tolerance", p->tolerance);
   if(up->zeropointset)
@@ -418,27 +418,27 @@ printvalues(FILE *fp, struct mkprofparams *p)
 
   fprintf(fp, "\n# Catalog:\n");
   if(up->xcolset)
-    fprintf(fp, CONF_SHOWFMT"%lu\n", "xcol", p->xcol);
+    fprintf(fp, CONF_SHOWFMT"%zu\n", "xcol", p->xcol);
   if(up->ycolset)
-    fprintf(fp, CONF_SHOWFMT"%lu\n", "ycol", p->ycol);
+    fprintf(fp, CONF_SHOWFMT"%zu\n", "ycol", p->ycol);
   if(up->racolset)
-    fprintf(fp, CONF_SHOWFMT"%lu\n", "racol", p->racol);
+    fprintf(fp, CONF_SHOWFMT"%zu\n", "racol", p->racol);
   if(up->deccolset)
-    fprintf(fp, CONF_SHOWFMT"%lu\n", "deccol", p->deccol);
+    fprintf(fp, CONF_SHOWFMT"%zu\n", "deccol", p->deccol);
   if(up->fcolset)
-    fprintf(fp, CONF_SHOWFMT"%lu\n", "fcol", p->fcol);
+    fprintf(fp, CONF_SHOWFMT"%zu\n", "fcol", p->fcol);
   if(up->rcolset)
-    fprintf(fp, CONF_SHOWFMT"%lu\n", "rcol", p->rcol);
+    fprintf(fp, CONF_SHOWFMT"%zu\n", "rcol", p->rcol);
   if(up->ncolset)
-    fprintf(fp, CONF_SHOWFMT"%lu\n", "ncol", p->ncol);
+    fprintf(fp, CONF_SHOWFMT"%zu\n", "ncol", p->ncol);
   if(up->pcolset)
-    fprintf(fp, CONF_SHOWFMT"%lu\n", "pcol", p->pcol);
+    fprintf(fp, CONF_SHOWFMT"%zu\n", "pcol", p->pcol);
   if(up->qcolset)
-    fprintf(fp, CONF_SHOWFMT"%lu\n", "qcol", p->qcol);
+    fprintf(fp, CONF_SHOWFMT"%zu\n", "qcol", p->qcol);
   if(up->mcolset)
-    fprintf(fp, CONF_SHOWFMT"%lu\n", "mcol", p->mcol);
+    fprintf(fp, CONF_SHOWFMT"%zu\n", "mcol", p->mcol);
   if(up->tcolset)
-    fprintf(fp, CONF_SHOWFMT"%lu\n", "tcol", p->tcol);
+    fprintf(fp, CONF_SHOWFMT"%zu\n", "tcol", p->tcol);
   if(up->mforflatpixset)
     fprintf(fp, CONF_SHOWFMT"%d\n", "mforflatpix", p->mforflatpix);
 
@@ -621,7 +621,7 @@ sanitycheck(struct mkprofparams *p)
     for(j=0;j<9;++j)
       if(i!=j && columns[i]==columns[j])
         error(EXIT_FAILURE, 0, "at least two of the specified columns "
-              "are set to %lu! By adding the `-P` or `--printparams` "
+              "are set to %zu! By adding the `-P` or `--printparams` "
               "option you can check the final column numbers. They "
               "all have to be different", columns[i]);
 
@@ -653,7 +653,7 @@ sanitycheck(struct mkprofparams *p)
   /* Check if all the profile codes are within the desired range: */
   for(i=0;i<p->cs0;++i)
     if(cat[i*cs1+p->fcol]<0 || cat[i*cs1+p->fcol]>MAXIMUMCODE)
-      error(EXIT_FAILURE, 0, "%s: In row %lu, the function code should"
+      error(EXIT_FAILURE, 0, "%s: In row %zu, the function code should"
             "be positive and smaller or equal to %d",
             p->up.catname, i+1, MAXIMUMCODE);
 
@@ -730,7 +730,7 @@ sanitycheck(struct mkprofparams *p)
       errno=0;
       p->outdir=malloc((strlen(p->cp.output)+1)*sizeof *p->outdir);
       if(p->outdir==NULL)
-        error(EXIT_FAILURE, errno, "%lu bytes for p->outdir in ui.c",
+        error(EXIT_FAILURE, errno, "%zu bytes for p->outdir in ui.c",
               (strlen(p->cp.output)+1)*sizeof *p->outdir);
       strcpy(p->outdir, p->cp.output);
       gal_checkset_check_dir_write_add_slash(&p->outdir);
@@ -776,7 +776,7 @@ preparewcs(struct mkprofparams *p)
   errno=0;
   wcs=p->wcs=malloc(sizeof *wcs);
   if(wcs==NULL)
-    error(EXIT_FAILURE, errno, "%lu for wcs in preparewcs", sizeof *wcs);
+    error(EXIT_FAILURE, errno, "%zu for wcs in preparewcs", sizeof *wcs);
 
   /* Initialize the structure (allocate all the arrays). */
   wcs->flag=-1;
@@ -836,7 +836,7 @@ preparearrays(struct mkprofparams *p)
   /* Allocate space for the log file: */
   p->log=malloc(p->cs0*LOGNUMCOLS*sizeof *p->log);
   if(p->log==NULL)
-    error(EXIT_FAILURE, 0, "Allocating %lu bytes for log file",
+    error(EXIT_FAILURE, 0, "Allocating %zu bytes for log file",
           p->cs0*LOGNUMCOLS*sizeof *p->log);
 
 
@@ -897,7 +897,7 @@ preparearrays(struct mkprofparams *p)
       errno=0;
       wcstoimg=malloc(4*p->cs0*sizeof *wcstoimg);
       if(wcstoimg==NULL)
-        error(EXIT_FAILURE, errno, "%lu bytes for wcstoimg",
+        error(EXIT_FAILURE, errno, "%zu bytes for wcstoimg",
               4*p->cs0*sizeof *wcstoimg);
 
 
@@ -1021,7 +1021,7 @@ setparams(int argc, char *argv[], struct mkprofparams *p)
       jobname=malloc(strlen(p->up.catname)+100*sizeof *jobname);
       if(jobname==NULL)
         error(EXIT_FAILURE, errno, "jobname in ui.c");
-      sprintf(jobname, "%lu profile%sread from %s", p->cs0,
+      sprintf(jobname, "%zu profile%sread from %s", p->cs0,
               p->cs0>1?"s ":" ", p->up.catname);
       gal_timing_report(&t1, jobname, 1);
       free(jobname);
@@ -1031,12 +1031,12 @@ setparams(int argc, char *argv[], struct mkprofparams 
*p)
       gal_timing_report(NULL, message, 1);
       if(p->envseed)
         {
-          sprintf(message, "RNG seed for all profiles: %lu",
+          sprintf(message, "RNG seed for all profiles: %zu",
                   gsl_rng_default_seed);
           gal_timing_report(NULL, message, 1);
         }
 
-      sprintf(message, "Using %lu threads.", cp->numthreads);
+      sprintf(message, "Using %zu threads.", cp->numthreads);
       gal_timing_report(NULL, message, 1);
     }
 }
diff --git a/bin/noisechisel/binary.c b/bin/noisechisel/binary.c
index 49090f6..f9c1cfd 100644
--- a/bin/noisechisel/binary.c
+++ b/bin/noisechisel/binary.c
@@ -524,7 +524,7 @@ fh_makeinv(unsigned char *byt, size_t s0, size_t s1,
   /* Allocate the temporary inverse array: */
   errno=0; tinv=malloc(size*sizeof *tinv);
   if(tinv==NULL)
-    error(EXIT_FAILURE, errno, "%lu bytes for tinv (binary.c)",
+    error(EXIT_FAILURE, errno, "%zu bytes for tinv (binary.c)",
           size*sizeof *tinv);
 
   /* Fill in the central regions of the inverse array: */
@@ -617,7 +617,7 @@ fillboundedholes(unsigned char *in, size_t s0, size_t s1, 
int anyblank)
   /* Allocate the array to keep the hole indexs */
   errno=0; hlab=malloc(idx*idy*sizeof *hlab);
   if(hlab==NULL)
-    error(EXIT_FAILURE, errno, "%lu bytes for hlab in filllabeledholes "
+    error(EXIT_FAILURE, errno, "%zu bytes for hlab in filllabeledholes "
           "(binary.c)", idx*idy*sizeof *hlab);
 
 
diff --git a/bin/noisechisel/clumps.c b/bin/noisechisel/clumps.c
index f9284d0..f18a898 100644
--- a/bin/noisechisel/clumps.c
+++ b/bin/noisechisel/clumps.c
@@ -503,14 +503,14 @@ getclumpinfo(struct clumpsthreadparams *ctp, double 
**outclumpinfo)
   if(x1-x0<=1 || y1-y0<=1)
     error(EXIT_FAILURE, 0, "a bug! Please contact us at %s so we can find "
           "and fix the problem in clumpinfo (clumps.c). For some reason, "
-          "the specified input region is %lu by %lu wide",
+          "the specified input region is %zu by %zu wide",
           PACKAGE_BUGREPORT, y1-y0, x1-x0);
 
   /* Allocate the clump information array. */
   errno=0;
   clumpinfo=calloc(ctp->numclumps*INFOTABCOLS, sizeof *clumpinfo);
   if(clumpinfo==NULL)
-    error(EXIT_FAILURE, errno, "%lu bytes for clumpinfo in getclumpinfo "
+    error(EXIT_FAILURE, errno, "%zu bytes for clumpinfo in getclumpinfo "
           "(clumps.c)", ctp->numclumps*INFOTABCOLS*sizeof *clumpinfo);
   *outclumpinfo=clumpinfo;
 
@@ -529,7 +529,7 @@ getclumpinfo(struct clumpsthreadparams *ctp, double 
**outclumpinfo)
     {
       errno=0; xys=calloc(3*ctp->numclumps, sizeof *xys);
       if(xys==NULL)
-        error(EXIT_FAILURE, errno, "%lu bytes for xys (clumps.c)",
+        error(EXIT_FAILURE, errno, "%zu bytes for xys (clumps.c)",
               3*ctp->numclumps*sizeof *xys);
     }
   else xys=NULL; /* To check if it is needed below. */
@@ -634,7 +634,7 @@ getclumpinfo(struct clumpsthreadparams *ctp, double 
**outclumpinfo)
                                                           xys[3*lab+2])];
 
                   /* For a check:
-                  printf("%lu: (%lu, %lu) --> %f\n", lab,
+                  printf("%zu: (%zu, %zu) --> %f\n", lab,
                          (size_t)(xys[3*lab+2] / clumpinfo[row]) +1,
                          (size_t)(xys[3*lab+1] / clumpinfo[row]) +1,
                          clumpinfo[row+4]);
@@ -654,7 +654,7 @@ getclumpinfo(struct clumpsthreadparams *ctp, double 
**outclumpinfo)
      (p->b0f1==0). set ctp->thislabel to the desired label.
   if(p->b0f1==1 && ctp->thislabel==1)
     for(i=1;i<ctp->numclumps;++i)
-      printf("%lu: %-10.3f %-5.0f %-10.3f %-5.0f %-10.3f\n", i,
+      printf("%zu: %-10.3f %-5.0f %-10.3f %-5.0f %-10.3f\n", i,
              clumpinfo[i*INFOTABCOLS], clumpinfo[i*INFOTABCOLS+1],
              clumpinfo[i*INFOTABCOLS+2], clumpinfo[i*INFOTABCOLS+3],
              clumpinfo[i*INFOTABCOLS+4]);
@@ -688,7 +688,7 @@ clumpsntable(struct clumpsthreadparams *ctp, float 
**sntable)
   errno=0;
   sntab = *sntable = malloc( ctp->numclumps * sizeof *sntab );
   if(sntab==NULL)
-    error(EXIT_FAILURE, errno, "%lu bytes for sntab (clumps.c)",
+    error(EXIT_FAILURE, errno, "%zu bytes for sntab (clumps.c)",
           ctp->numclumps*sizeof *sntab);
 
 
@@ -740,7 +740,7 @@ clumpsntable(struct clumpsthreadparams *ctp, float 
**sntable)
   if(p->b0f1==1 && ctp->thislabel==151)
     {
       for(i=1;i<ctp->numclumps;++i)
-        printf("%lu: %-10.3g %-5.0f %-10.3g(%-5.0f) --> %-10.3g\n", i,
+        printf("%zu: %-10.3g %-5.0f %-10.3g(%-5.0f) --> %-10.3g\n", i,
                clumpinfo[i*INFOTABCOLS], clumpinfo[i*INFOTABCOLS+1],
                clumpinfo[i*INFOTABCOLS+2], clumpinfo[i*INFOTABCOLS+3],
                sntab[i]);
@@ -883,11 +883,11 @@ findclumpsn(struct noisechiselparams *p)
      in each mesh. */
   errno=0; p->numclumpsarr=malloc(nmeshi*sizeof*p->numclumpsarr);
   if(p->numclumpsarr==NULL)
-    error(EXIT_FAILURE, errno, "%lu bytes for p->numclumpsarr in "
+    error(EXIT_FAILURE, errno, "%zu bytes for p->numclumpsarr in "
           "findclumpsn (clumps.c)", nmeshi*sizeof*p->numclumpsarr);
   errno=0; p->sntablearr=malloc(nmeshi*sizeof*p->sntablearr);
   if(p->sntablearr==NULL)
-    error(EXIT_FAILURE, errno, "%lu bytes for p->sntablearr in "
+    error(EXIT_FAILURE, errno, "%zu bytes for p->sntablearr in "
           "findclumpsn (clumps.c)", nmeshi*sizeof*p->sntablearr);
 
 
@@ -900,7 +900,7 @@ findclumpsn(struct noisechiselparams *p)
   for(i=0;i<nmeshi;++i) numclumps+=p->numclumpsarr[i];
   errno=0; sntable=malloc(numclumps*sizeof*sntable);
   if(sntable==NULL)
-    error(EXIT_FAILURE, errno, "%lu bytes for sntable in "
+    error(EXIT_FAILURE, errno, "%zu bytes for sntable in "
           "findclumpsn (clumps.c)", numclumps*sizeof*sntable);
 
 
@@ -961,7 +961,7 @@ removefalseclumps(struct clumpsthreadparams *ctp, float 
*sntable)
   /* Allocate space for the new labels array. */
   errno=0; newlabs=malloc(ctp->numclumps*sizeof *newlabs);
   if(newlabs==NULL)
-    error(EXIT_FAILURE, errno, "%lu bytes for newlabs in "
+    error(EXIT_FAILURE, errno, "%zu bytes for newlabs in "
           "removefalsedetections (clumps.c)",
           ctp->numclumps*sizeof *newlabs);
 
diff --git a/bin/noisechisel/detection.c b/bin/noisechisel/detection.c
index da0d4f8..d3f57db 100644
--- a/bin/noisechisel/detection.c
+++ b/bin/noisechisel/detection.c
@@ -104,7 +104,7 @@ initialdetection(struct noisechiselparams *p)
                            SPACK_STRING);
   if(verb)
     {
-      sprintf(report, "Eroded %lu times (%s connectivity).",
+      sprintf(report, "Eroded %zu times (%s connectivity).",
               p->erode, p->erodengb==4 ? "4" : "8");
       gal_timing_report(NULL, report, 2);
     }
@@ -120,7 +120,7 @@ initialdetection(struct noisechiselparams *p)
                            SPACK_STRING);
   if(verb)
     {
-      sprintf(report, "Opened (depth: %lu, %s connectivity).",
+      sprintf(report, "Opened (depth: %zu, %s connectivity).",
               p->opening, p->openingngb==4 ? "4" : "8");
       gal_timing_report(NULL, report, 2);
     }
@@ -178,25 +178,25 @@ detlabelsn(struct noisechiselparams *p, size_t *numlabs, 
float **outsntable)
   /* Allocate the necessary arrays to keep the label information: */
   errno=0; sntable=*outsntable=calloc(*numlabs, sizeof *sntable);
   if(sntable==NULL)
-    error(EXIT_FAILURE, errno, "%lu bytes for sntable in detlabelsn "
+    error(EXIT_FAILURE, errno, "%zu bytes for sntable in detlabelsn "
           "(detection.c)", *numlabs*sizeof *sntable);
   errno=0; brightnesses=calloc(*numlabs, sizeof *brightnesses);
   if(brightnesses==NULL)
-    error(EXIT_FAILURE, errno, "%lu bytes for brightnesses in detlabelsn "
+    error(EXIT_FAILURE, errno, "%zu bytes for brightnesses in detlabelsn "
           "(detection.c)", *numlabs*sizeof *brightnesses);
   errno=0; xys=calloc(*numlabs*xyscol, sizeof *xys);
   if(xys==NULL)
-    error(EXIT_FAILURE, errno, "%lu bytes for xys in detlabelsn "
+    error(EXIT_FAILURE, errno, "%zu bytes for xys in detlabelsn "
           "(detection.c)", *numlabs*sizeof *xys);
   errno=0; areas=calloc(*numlabs, sizeof *areas);
   if(areas==NULL)
-    error(EXIT_FAILURE, errno, "%lu bytes for areas in detlabelsn "
+    error(EXIT_FAILURE, errno, "%zu bytes for areas in detlabelsn "
           "(detection.c)", *numlabs*sizeof *areas);
   if(b0f1==0)
     {
       errno=0; coversdet=calloc(*numlabs, sizeof *coversdet);
       if(coversdet==NULL)
-        error(EXIT_FAILURE, errno, "%lu bytes for coversdet in detlabelsn "
+        error(EXIT_FAILURE, errno, "%zu bytes for coversdet in detlabelsn "
               "(detection.c)", *numlabs*sizeof *coversdet);
     }
 
@@ -302,7 +302,7 @@ detlabelsn(struct noisechiselparams *p, size_t *numlabs, 
float **outsntable)
   if(b0f1)
     {
       for(i=0;i<*numlabs;++i)
-        printf("%lu: %-10ld %-10.3f %-10.3f\n",
+        printf("%zu: %-10ld %-10.3f %-10.3f\n",
                i, areas[i], brightnesses[i], sntable[i]);
     }
   */
@@ -329,7 +329,7 @@ applydetsn(struct noisechiselparams *p, float *sntable, 
size_t numpseudo)
 
   errno=0; newlabs=calloc(numpseudo, sizeof *newlabs);
   if(newlabs==NULL)
-    error(EXIT_FAILURE, errno, "%lu bytes for numlabs in "
+    error(EXIT_FAILURE, errno, "%zu bytes for numlabs in "
           "removefalsedetections (detections.c)",
           numpseudo*sizeof *newlabs);
 
@@ -621,7 +621,7 @@ dbytolaboverlap(struct noisechiselparams *p)
   /* Allocate array to keep the overlapping labels. */
   errno=0; tokeep=calloc(numobjects, sizeof*tokeep);
   if(tokeep==NULL)
-    error(EXIT_FAILURE, errno, "%lu bytes for tokeep in dbytolaboverlap "
+    error(EXIT_FAILURE, errno, "%zu bytes for tokeep in dbytolaboverlap "
           "(detection.c)", numobjects*sizeof*tokeep);
 
 
@@ -755,7 +755,7 @@ onlytruedetections(struct noisechiselparams *p)
                            p->wcs, NULL, SPACK_STRING);
   if(verb)
     {            /* p->numobjects changed in dbytlaboverlap. */
-      sprintf(report, "%lu false detections removed.",
+      sprintf(report, "%zu false detections removed.",
               numobjects-p->numobjects);
       gal_timing_report(NULL, report, 2);
     }
diff --git a/bin/noisechisel/label.c b/bin/noisechisel/label.c
index 1dd88b5..3cf1b65 100644
--- a/bin/noisechisel/label.c
+++ b/bin/noisechisel/label.c
@@ -70,7 +70,7 @@ BF_concmp(unsigned char *byt, long *lab, size_t s0, size_t s1,
   if(connectivity!=4 && connectivity!=8)
     error(EXIT_FAILURE, 0, "a bug! Please contact us at %s so we can fix "
           "the problem. For some reason, the value to connectivity in "
-          "BF_concmp (label.c) is %lu which is not recognized",
+          "BF_concmp (label.c) is %zu which is not recognized",
           PACKAGE_BUGREPORT, connectivity);
 
 
@@ -227,7 +227,7 @@ BF_concomp_AdjMatrix(int *adj, size_t numside, long 
**outnewlabs)
   errno=0;
   newlabs=calloc(numside, sizeof *newlabs);
   if(newlabs==NULL)
-    error(EXIT_FAILURE, errno, "%lu bytes for newlabs in "
+    error(EXIT_FAILURE, errno, "%zu bytes for newlabs in "
           "BF_concomp_AdjMatrix (label.c)", numside*sizeof *newlabs);
 
   for(i=1;i<numside;++i)
@@ -250,7 +250,7 @@ BF_concomp_AdjMatrix(int *adj, size_t numside, long 
**outnewlabs)
 
   /* For a check:
   for(i=1;i<numside;++i)
-    printf("%lu: %ld\n", i, newlabs[i]);
+    printf("%zu: %ld\n", i, newlabs[i]);
   */
 
   *outnewlabs=newlabs;
@@ -292,7 +292,7 @@ labareas(long *lab, size_t size, size_t numlabs, size_t 
**outareas)
   errno=0;
   areas=*outareas=calloc(numlabs, sizeof *areas);
   if(areas==NULL)
-    error(EXIT_FAILURE, errno, "%lu bytes for areas in labareas (label.c)",
+    error(EXIT_FAILURE, errno, "%zu bytes for areas in labareas (label.c)",
           numlabs*sizeof *areas);
 
   /* Find the area of each label. */
@@ -300,7 +300,7 @@ labareas(long *lab, size_t size, size_t numlabs, size_t 
**outareas)
 
   /* For a check:
   for(i=0;i<numlabs;++i)
-    printf("%lu: %ld\n", i, a[i]);
+    printf("%zu: %ld\n", i, a[i]);
   printf("\n\n\n\n\n");
   */
 }
@@ -319,7 +319,7 @@ removesmallarea_relabel(long *in, unsigned char *byt, 
size_t size,
   /* Allocate the space to keep the new labels. */
   errno=0; newlabs=calloc(*numlabs, sizeof *newlabs);
   if(newlabs==NULL)
-    error(EXIT_FAILURE, errno, "%lu bytes for newlabs in "
+    error(EXIT_FAILURE, errno, "%zu bytes for newlabs in "
           "removesmallarea_relabel (label.c)", *numlabs*sizeof *newlabs);
 
   /* Find the areas: */
@@ -369,7 +369,7 @@ labindexs(long *inlab, size_t size, size_t numlabs, size_t 
**outareas,
   errno=0;
   labinds=*outlabinds=malloc(numlabs*sizeof *labinds);
   if(labinds==NULL)
-    error(EXIT_FAILURE, errno, "%lu bytes for labinds in labindexs "
+    error(EXIT_FAILURE, errno, "%zu bytes for labinds in labindexs "
           "(label.c)", numlabs*sizeof *labinds);
   labinds[0]=NULL;
 
@@ -383,7 +383,7 @@ labindexs(long *inlab, size_t size, size_t numlabs, size_t 
**outareas,
   errno=0;
   counters=calloc(numlabs, sizeof *counters);
   if(counters==NULL)
-    error(EXIT_FAILURE, errno, "%lu bytes for counters in labindexs "
+    error(EXIT_FAILURE, errno, "%zu bytes for counters in labindexs "
           "(label.c)", numlabs*sizeof *counters);
 
   /* Allocate space for each label's indexs: */
@@ -392,7 +392,7 @@ labindexs(long *inlab, size_t size, size_t numlabs, size_t 
**outareas,
       errno=0;
       labinds[i]=malloc(areas[i]*sizeof **labinds);
       if(labinds[i]==NULL)
-        error(EXIT_FAILURE, errno, "%lu bytes for labinds[%lu] in "
+        error(EXIT_FAILURE, errno, "%zu bytes for labinds[%zu] in "
               "labindexs (label.c)", areas[i]*sizeof **labinds, i);
     }
 
@@ -409,9 +409,9 @@ labindexs(long *inlab, size_t size, size_t numlabs, size_t 
**outareas,
     size_t j;
     for(i=1;i<numlabs;++i)
       {
-        printf("Lab: %lu\n", i);
+        printf("Lab: %zu\n", i);
         for(j=0;j<areas[i];++j)
-          printf("  %lu\n", labinds[i][j]);
+          printf("  %zu\n", labinds[i][j]);
       }
     exit(0);
   }
diff --git a/bin/noisechisel/noisechisel.c b/bin/noisechisel/noisechisel.c
index 9d0afe5..a835465 100644
--- a/bin/noisechisel/noisechisel.c
+++ b/bin/noisechisel/noisechisel.c
@@ -173,7 +173,7 @@ noisechisel(struct noisechiselparams *p)
   initialdetection(p);
   if(verb)
     {
-      sprintf(report, "%lu initial detections found.", p->numobjects-1);
+      sprintf(report, "%zu initial detections found.", p->numobjects-1);
       gal_timing_report(&t1, report, 1);
     }
 
@@ -189,7 +189,7 @@ noisechisel(struct noisechiselparams *p)
   onlytruedetections(p);
   if(verb)
     {
-      sprintf(report, "%lu true detections identified.", p->numobjects-1);
+      sprintf(report, "%zu true detections identified.", p->numobjects-1);
       gal_timing_report(&t1, report, 1);
     }
 
@@ -210,7 +210,7 @@ noisechisel(struct noisechiselparams *p)
       p->numobjects=BF_concmp(p->byt, p->olab, s0, s1, p->anyblank, 8);
       if(verb)
         {
-          sprintf(report, "%lu detections after %lu dilation%s",
+          sprintf(report, "%zu detections after %zu dilation%s",
                   p->numobjects-1, p->dilate, p->dilate>1 ? "s." : ".");
           gal_timing_report(&t1, report, 1);
         }
@@ -280,7 +280,7 @@ noisechisel(struct noisechiselparams *p)
       segmentation(p);
       if(verb)
         {
-          sprintf(report, "%lu object%s""containing %lu clump%sfound.",
+          sprintf(report, "%zu object%s""containing %zu clump%sfound.",
                   p->numobjects-1, p->numobjects==2 ? " " : "s ",
                   p->numclumps-1,  p->numclumps ==2 ? " " : "s ");
           gal_timing_report(&t1, report, 1);
@@ -296,7 +296,7 @@ noisechisel(struct noisechiselparams *p)
     {
       errno=0; oreport=malloc(strlen(p->cp.output)+100*sizeof *oreport);
       if(oreport==NULL)
-        error(EXIT_FAILURE, errno, "%lu bytes for oreport in noisechisel "
+        error(EXIT_FAILURE, errno, "%zu bytes for oreport in noisechisel "
               "(noisechisel.c)", strlen(p->cp.output)+100*sizeof *oreport);
       sprintf(oreport, "Output written to %s.", p->cp.output);
       gal_timing_report(&t1, oreport, 1);
diff --git a/bin/noisechisel/segmentation.c b/bin/noisechisel/segmentation.c
index 48d056a..8bd2d6a 100644
--- a/bin/noisechisel/segmentation.c
+++ b/bin/noisechisel/segmentation.c
@@ -106,7 +106,7 @@ prepfirstgrowth(struct clumpsthreadparams *ctp)
   errno=0;
   ctp->blankinds=malloc(ctp->area*sizeof *ctp->blankinds);
   if(ctp->blankinds==NULL)
-    error(EXIT_FAILURE, errno, "%lu bytes for ctp->blankpixels in "
+    error(EXIT_FAILURE, errno, "%zu bytes for ctp->blankpixels in "
           "prepfirstgrowth (clumps.c)", ctp->area*sizeof *ctp->blankinds);
   ctp->numblanks=0;
   indf=(ind=ctp->inds)+ctp->area;
@@ -261,10 +261,10 @@ adjacencymatrixs(struct clumpsthreadparams *ctp,
   if(ctp->thislabel==104)
     for(i=1;i<numclumps;++i)
       {
-        printf("%lu: \n", i);
+        printf("%zu: \n", i);
         for(j=1;j<numclumps;++j)
           if(nums[ i * numclumps + j])
-            printf("   %lu: %-4d %-10.2f %-10.3f\n", j,
+            printf("   %zu: %-4d %-10.2f %-10.3f\n", j,
                    nums[i*numclumps+j],
                    sums[i*numclumps+j]/nums[i*numclumps+j],
                    sns[i*numclumps+j]);
@@ -299,15 +299,15 @@ grownclumpstoobjects(struct clumpsthreadparams *ctp)
   /* Allocate the necessary arrays: */
   errno=0; nums=calloc(numclumps*numclumps, sizeof *nums);
   if(nums==NULL)
-    error(EXIT_FAILURE, errno, "%lu bytes for nums in grownclumpstoobjects "
+    error(EXIT_FAILURE, errno, "%zu bytes for nums in grownclumpstoobjects "
           "(segmentation.c)", numclumps*numclumps*sizeof *nums);
   errno=0; sums=calloc(numclumps*numclumps, sizeof *sums);
   if(sums==NULL)
-    error(EXIT_FAILURE, errno, "%lu bytes for sums in grownclumpstoobjects "
+    error(EXIT_FAILURE, errno, "%zu bytes for sums in grownclumpstoobjects "
           "(segmentation.c)", numclumps*numclumps*sizeof *sums);
   errno=0; sns=calloc(numclumps*numclumps, sizeof *sns);
   if(sns==NULL)
-    error(EXIT_FAILURE, errno, "%lu bytes for sns in grownclumpstoobjects "
+    error(EXIT_FAILURE, errno, "%zu bytes for sns in grownclumpstoobjects "
           "(segmentation.c)", numclumps*numclumps*sizeof *sns);
 
 
@@ -369,9 +369,9 @@ newclumplabels(struct clumpsthreadparams *ctp)
   if(ctp->numclumps<=2 || ctp->numobjects<=2)
     error(EXIT_FAILURE, 0, "a bug! Please contact us at %s so we can fix "
           "it. For some reason, the newclumplabels function (in "
-          "segmentation.c) was called for the %lu detected region, even "
-          "though this region has ctp->numclumps=%lu and "
-          "ctp->numobjects=%lu! This function should only be used when "
+          "segmentation.c) was called for the %zu detected region, even "
+          "though this region has ctp->numclumps=%zu and "
+          "ctp->numobjects=%zu! This function should only be used when "
           "there is more than one object and clump over a detected region",
           PACKAGE_BUGREPORT, ctp->thislabel, ctp->numclumps,
           ctp->numobjects);
@@ -382,7 +382,7 @@ newclumplabels(struct clumpsthreadparams *ctp)
   errno=0;
   numclumpsinobj=calloc(ctp->numobjects, sizeof *numclumpsinobj);
   if(numclumpsinobj==NULL)
-    error(EXIT_FAILURE, errno, "%lu bytes for numclumpsinobj in "
+    error(EXIT_FAILURE, errno, "%zu bytes for numclumpsinobj in "
           "newclumplabels (segmentation.c)",
           ctp->numobjects*sizeof *numclumpsinobj);
 
@@ -391,7 +391,7 @@ newclumplabels(struct clumpsthreadparams *ctp)
   errno=0;
   newclumplabs=calloc(ctp->numclumps, sizeof *newclumplabs);
   if(newclumplabs==NULL)
-    error(EXIT_FAILURE, errno, "%lu bytes for newclumplabs in "
+    error(EXIT_FAILURE, errno, "%zu bytes for newclumplabs in "
           "newclumplabels (segmentation.c)",
           ctp->numclumps*sizeof *newclumplabs);
 
@@ -499,7 +499,7 @@ segmentonthread(void *inparam)
            space equal to the number of pixels*/
         errno=0; ctp->topinds=malloc(ctp->area*sizeof *ctp->topinds);
         if(ctp->topinds==NULL)
-          error(EXIT_FAILURE, errno, "%lu bytes for ctp->topinds in "
+          error(EXIT_FAILURE, errno, "%zu bytes for ctp->topinds in "
                 "segmentonthread (segmentation.c)",
                 ctp->area*sizeof *ctp->topinds);
 
@@ -643,7 +643,7 @@ segmentdetections(struct noisechiselparams *p, size_t 
numobjsinit,
      thread. */
   errno=0; ctp=malloc(numthreads*sizeof *ctp);
   if(ctp==NULL)
-    error(EXIT_FAILURE, errno, "%lu bytes in segmentdetections "
+    error(EXIT_FAILURE, errno, "%zu bytes in segmentdetections "
           "(segmentation.c) for ctp", numthreads*sizeof *ctp);
 
 
@@ -687,7 +687,7 @@ segmentdetections(struct noisechiselparams *p, size_t 
numobjsinit,
             ctp[i].totalnummtx=&totalnummtx;
             ctp[i].indexs=&indexs[i*thrdcols];
             err=pthread_create(&t, &attr, segmentonthread, &ctp[i]);
-            if(err) error(EXIT_FAILURE, 0, "can't create thread %lu", i);
+            if(err) error(EXIT_FAILURE, 0, "can't create thread %zu", i);
           }
 
       /* Wait for all threads to finish and free the spaces. */
diff --git a/bin/noisechisel/thresh.c b/bin/noisechisel/thresh.c
index de4629d..f7e6d12 100644
--- a/bin/noisechisel/thresh.c
+++ b/bin/noisechisel/thresh.c
@@ -259,7 +259,7 @@ applydetectionthresholdskysub(struct noisechiselparams *p)
   /* Allocate the array to keep the threshold value: */
   errno=0; dbyt=p->dbyt=malloc(is0*is1*sizeof *p->dbyt);
   if(dbyt==NULL)
-    error(EXIT_FAILURE, errno, "%lu bytes for dbyt in "
+    error(EXIT_FAILURE, errno, "%zu bytes for dbyt in "
           "applydetectionthreshold (detection.c)", is0*is1*sizeof *dbyt);
 
 
@@ -342,9 +342,9 @@ snthresh(struct noisechiselparams *p, float *sntable, 
size_t size,
 
   /* Check if the number is acceptable to the user. */
   if(size<p->minnumfalse)
-    error(EXIT_FAILURE, 0, "there are only %lu %s in the sky region of "
+    error(EXIT_FAILURE, 0, "there are only %zu %s in the sky region of "
           "the image. This is smaller than the minimum number you "
-          "specified: %lu. You can decrease this minimum with the "
+          "specified: %zu. You can decrease this minimum with the "
           "`--minnumfalse' (`-F') option or you can decrease the other "
           "parameters that determine the %s. See the GNU Astronomy "
           "Utilities manual (section on NoiseChisel) or Akhlaghi and "
@@ -369,7 +369,7 @@ snthresh(struct noisechiselparams *p, float *sntable, 
size_t size,
   sn=sntable[gal_statistics_index_from_quantile(size, quant)];
   if(p->cp.verb)
     {
-      sprintf(report, "%s S/N: %.3f (%.3f quantile of %lu %s).",
+      sprintf(report, "%s S/N: %.3f (%.3f quantile of %zu %s).",
               job, sn, quant, size, name);
       gal_timing_report(NULL, report, 2);
     }
@@ -392,7 +392,7 @@ snthresh(struct noisechiselparams *p, float *sntable, 
size_t size,
          safey free it. */
       sprintf(cline, "# %s\n# %s started on %s"
               "# Input: %s (hdu: %s)\n"
-              "# S/N distribution histogram of %lu sky %s.\n"
+              "# S/N distribution histogram of %zu sky %s.\n"
               "# The %.3f quantile has an S/N of %.4f.",
               SPACK_STRING, SPACK_NAME, ctime(&p->rawtime),
               p->up.inputname, p->cp.hdu, size, name, quant, sn);
diff --git a/bin/noisechisel/ui.c b/bin/noisechisel/ui.c
index 870809f..31e88d6 100644
--- a/bin/noisechisel/ui.c
+++ b/bin/noisechisel/ui.c
@@ -90,7 +90,7 @@ readconfig(char *filename, struct noisechiselparams *p)
   errno=0;
   line=malloc(len*sizeof *line);
   if(line==NULL)
-    error(EXIT_FAILURE, errno, "ui.c: %lu bytes in readdefaults",
+    error(EXIT_FAILURE, errno, "ui.c: %zu bytes in readdefaults",
           len * sizeof *line);
 
   /* Read the tokens in the file:  */
@@ -431,7 +431,7 @@ printvalues(FILE *fp, struct noisechiselparams *p)
   if(up->minbfracset)
     fprintf(fp, CONF_SHOWFMT"%.3f\n", "minbfrac", p->minbfrac);
   if(up->minnumfalseset)
-    fprintf(fp, CONF_SHOWFMT"%lu\n", "minnumfalse", p->minnumfalse);
+    fprintf(fp, CONF_SHOWFMT"%zu\n", "minnumfalse", p->minnumfalse);
 
 
   fprintf(fp, "\n# Output:\n");
@@ -443,13 +443,13 @@ printvalues(FILE *fp, struct noisechiselparams *p)
 
   fprintf(fp, "\n# Mesh grid:\n");
   if(up->smeshsizeset)
-    fprintf(fp, CONF_SHOWFMT"%lu\n", "smeshsize", smp->meshsize);
+    fprintf(fp, CONF_SHOWFMT"%zu\n", "smeshsize", smp->meshsize);
   if(up->lmeshsizeset)
-    fprintf(fp, CONF_SHOWFMT"%lu\n", "lmeshsize", lmp->meshsize);
+    fprintf(fp, CONF_SHOWFMT"%zu\n", "lmeshsize", lmp->meshsize);
   if(up->nch1set)
-    fprintf(fp, CONF_SHOWFMT"%lu\n", "nch1", smp->nch1);
+    fprintf(fp, CONF_SHOWFMT"%zu\n", "nch1", smp->nch1);
   if(up->nch2set)
-    fprintf(fp, CONF_SHOWFMT"%lu\n", "nch2", smp->nch2);
+    fprintf(fp, CONF_SHOWFMT"%zu\n", "nch2", smp->nch2);
   if(up->lastmeshfracset)
     fprintf(fp, CONF_SHOWFMT"%.3f\n", "lastmeshfrac", smp->lastmeshfrac);
   if(up->mirrordistset)
@@ -457,9 +457,9 @@ printvalues(FILE *fp, struct noisechiselparams *p)
   if(up->minmodeqset)
     fprintf(fp, CONF_SHOWFMT"%.3f\n", "minmodeq", smp->minmodeq);
   if(up->numnearestset)
-    fprintf(fp, CONF_SHOWFMT"%lu\n", "numnearest", smp->numnearest);
+    fprintf(fp, CONF_SHOWFMT"%zu\n", "numnearest", smp->numnearest);
   if(up->smoothwidthset)
-    fprintf(fp, CONF_SHOWFMT"%lu\n", "smoothwidth", smp->smoothwidth);
+    fprintf(fp, CONF_SHOWFMT"%zu\n", "smoothwidth", smp->smoothwidth);
   if(up->fullconvolutionset)
     fprintf(fp, CONF_SHOWFMT"%d\n", "fullconvolution",
             smp->fullconvolution);
@@ -474,13 +474,13 @@ printvalues(FILE *fp, struct noisechiselparams *p)
   if(up->qthreshset)
     fprintf(fp, CONF_SHOWFMT"%.3f\n", "qthresh", p->qthresh);
   if(up->erodeset)
-    fprintf(fp, CONF_SHOWFMT"%lu\n", "erode", p->erode);
+    fprintf(fp, CONF_SHOWFMT"%zu\n", "erode", p->erode);
   if(up->erodengbset)
     fprintf(fp, CONF_SHOWFMT"%d\n", "erodengb", p->erodengb);
   if(up->noerodequantset)
     fprintf(fp, CONF_SHOWFMT"%.3f\n", "noerodequant", p->noerodequant);
   if(up->openingset)
-    fprintf(fp, CONF_SHOWFMT"%lu\n", "opening", p->opening);
+    fprintf(fp, CONF_SHOWFMT"%zu\n", "opening", p->opening);
   if(up->openingngbset)
     fprintf(fp, CONF_SHOWFMT"%d\n", "openingngb", p->openingngb);
   if(up->sigclipmultipset)
@@ -491,28 +491,28 @@ printvalues(FILE *fp, struct noisechiselparams *p)
   if(up->dthreshset)
     fprintf(fp, CONF_SHOWFMT"%.3f\n", "dthresh", p->dthresh);
   if(up->detsnminareaset)
-    fprintf(fp, CONF_SHOWFMT"%lu\n", "detsnminarea", p->detsnminarea);
+    fprintf(fp, CONF_SHOWFMT"%zu\n", "detsnminarea", p->detsnminarea);
   if(up->detsnhistnbinsset)
-    fprintf(fp, CONF_SHOWFMT"%lu\n", "detsnhistnbins", p->detsnhistnbins);
+    fprintf(fp, CONF_SHOWFMT"%zu\n", "detsnhistnbins", p->detsnhistnbins);
   if(up->detquantset)
     fprintf(fp, CONF_SHOWFMT"%.3f\n", "detquant", p->detquant);
   if(up->dilateset)
-    fprintf(fp, CONF_SHOWFMT"%lu\n", "dilate", p->dilate);
+    fprintf(fp, CONF_SHOWFMT"%zu\n", "dilate", p->dilate);
 
 
   fprintf(fp, "\n# Segmentation:\n");
   if(up->segsnminareaset)
-    fprintf(fp, CONF_SHOWFMT"%lu\n", "segsnminarea", p->segsnminarea);
+    fprintf(fp, CONF_SHOWFMT"%zu\n", "segsnminarea", p->segsnminarea);
   if(up->keepmaxnearriverset)
     fprintf(fp, CONF_SHOWFMT"%d\n", "keepmaxnearriver", p->keepmaxnearriver);
   if(up->segquantset)
     fprintf(fp, CONF_SHOWFMT"%.3f\n", "segquant", p->segquant);
   if(up->clumpsnhistnbinsset)
-    fprintf(fp, CONF_SHOWFMT"%lu\n", "clumpsnhistnbins", p->clumpsnhistnbins);
+    fprintf(fp, CONF_SHOWFMT"%zu\n", "clumpsnhistnbins", p->clumpsnhistnbins);
   if(up->gthreshset)
     fprintf(fp, CONF_SHOWFMT"%.3f\n", "gthresh", p->gthresh);
   if(up->minriverlengthset)
-    fprintf(fp, CONF_SHOWFMT"%lu\n", "minriverlength", p->minriverlength);
+    fprintf(fp, CONF_SHOWFMT"%zu\n", "minriverlength", p->minriverlength);
   if(up->objbordersnset)
     fprintf(fp, CONF_SHOWFMT"%.3f\n", "objbordersn", p->objbordersn);
 
@@ -752,7 +752,7 @@ sanitycheck(struct noisechiselparams *p)
   /* Other checks: */
   if(smp->numnearest<GAL_MESH_MIN_ACCEPTABLE_NEAREST)
     error(EXIT_FAILURE, 0, "the smallest possible number for `--numnearest' "
-          "(`-n') is %d. You have asked for: %lu",
+          "(`-n') is %d. You have asked for: %zu",
           GAL_MESH_MIN_ACCEPTABLE_NEAREST, smp->numnearest);
 }
 
@@ -855,8 +855,8 @@ preparearrays(struct noisechiselparams *p)
 
   /* make sure the channel sizes fit the channel sizes. */
   if( s0%smp->nch2 || s1%smp->nch1 )
-    error(EXIT_FAILURE, 0, "the input image size (%lu x %lu) is not an "
-          "exact multiple of the number of the given channels (%lu, %lu) "
+    error(EXIT_FAILURE, 0, "the input image size (%zu x %zu) is not an "
+          "exact multiple of the number of the given channels (%zu, %zu) "
           "in the respective axis", s1, s0, smp->nch1, smp->nch2);
 
   /* p->imgss (image-sky-subtracted) is the sky subtracted input
@@ -880,7 +880,7 @@ preparearrays(struct noisechiselparams *p)
      doesn't have to be allocated and de-allocated on every step.  */
   errno=0; p->imgss=malloc(s0*s1*sizeof *p->imgss);
   if(p->imgss==NULL)
-    error(EXIT_FAILURE, errno, "%lu bytes for p->imgss in preparearrays "
+    error(EXIT_FAILURE, errno, "%zu bytes for p->imgss in preparearrays "
           "(ui.c)", s0*s1*sizeof *p->imgss);
 
   /* Read the kernel: */
@@ -894,7 +894,7 @@ preparearrays(struct noisechiselparams *p)
       smp->ks1=defaultkernel_s1;
       smp->kernel=malloc(smp->ks0*smp->ks1*sizeof *smp->kernel);
       if(smp->kernel==NULL)
-        error(EXIT_FAILURE, errno, "%lu bytes for default kernel",
+        error(EXIT_FAILURE, errno, "%zu bytes for default kernel",
               smp->ks0*smp->ks1);
       ff=defaultkernel;
       fp=(f=smp->kernel)+smp->ks0*smp->ks1;
@@ -904,15 +904,15 @@ preparearrays(struct noisechiselparams *p)
   /* Allocate the other necessary arrays: */
   errno=0; p->byt=malloc(s0*s1*sizeof *p->byt);
   if(p->byt==NULL)
-    error(EXIT_FAILURE, errno, "%lu bytes for p->byt (ui.c)",
+    error(EXIT_FAILURE, errno, "%zu bytes for p->byt (ui.c)",
           s0*s1*sizeof *p->byt);
   errno=0; p->olab=malloc(s0*s1*sizeof *p->olab);
   if(p->olab==NULL)
-    error(EXIT_FAILURE, errno, "%lu bytes for p->olab (ui.c)",
+    error(EXIT_FAILURE, errno, "%zu bytes for p->olab (ui.c)",
           s0*s1*sizeof *p->olab);
   errno=0; p->clab=malloc(s0*s1*sizeof *p->clab);
   if(p->clab==NULL)
-    error(EXIT_FAILURE, errno, "%lu bytes for p->clab (ui.c)",
+    error(EXIT_FAILURE, errno, "%zu bytes for p->clab (ui.c)",
           s0*s1*sizeof *p->clab);
 
   /* This ngb array is used to keep the relative indexs of the
@@ -1031,7 +1031,7 @@ setparams(int argc, char *argv[], struct 
noisechiselparams *p)
   if(cp->verb)
     {
       printf(SPACK_NAME" started on %s", ctime(&p->rawtime));
-      printf("  - Using %lu CPU thread%s\n", p->cp.numthreads,
+      printf("  - Using %zu CPU thread%s\n", p->cp.numthreads,
              p->cp.numthreads==1 ? "." : "s.");
       printf("  - Input: %s (hdu: %s)\n", p->up.inputname, p->cp.hdu);
       if(p->up.maskname)
diff --git a/bin/subtractsky/subtractsky.c b/bin/subtractsky/subtractsky.c
index e903152..a6e91f2 100644
--- a/bin/subtractsky/subtractsky.c
+++ b/bin/subtractsky/subtractsky.c
@@ -64,7 +64,7 @@ avestdonthread(void *inparam)
     {
       errno=0; cofa=malloc(mp->maxs0*mp->maxs1*sizeof *oneforall);
       if(cofa==NULL)
-        error(EXIT_FAILURE, errno, "unable to allocate %lu bytes for"
+        error(EXIT_FAILURE, errno, "unable to allocate %zu bytes for"
               "cofa in avestdonthread of subtractsky.c",
               mp->maxs0*mp->maxs1*sizeof *mp->img);
     }
diff --git a/bin/subtractsky/ui.c b/bin/subtractsky/ui.c
index 958c1bc..d170092 100644
--- a/bin/subtractsky/ui.c
+++ b/bin/subtractsky/ui.c
@@ -90,7 +90,7 @@ readconfig(char *filename, struct subtractskyparams *p)
   errno=0;
   line=malloc(len*sizeof *line);
   if(line==NULL)
-    error(EXIT_FAILURE, errno, "ui.c: %lu bytes in readdefaults",
+    error(EXIT_FAILURE, errno, "ui.c: %zu bytes in readdefaults",
           len * sizeof *line);
 
   /* Read the tokens in the file:  */
@@ -294,11 +294,11 @@ printvalues(FILE *fp, struct subtractskyparams *p)
 
   fprintf(fp, "\n# Mesh grid:\n");
   if(up->meshsizeset)
-    fprintf(fp, CONF_SHOWFMT"%lu\n", "meshsize", mp->meshsize);
+    fprintf(fp, CONF_SHOWFMT"%zu\n", "meshsize", mp->meshsize);
   if(up->nch1set)
-    fprintf(fp, CONF_SHOWFMT"%lu\n", "nch1", mp->nch1);
+    fprintf(fp, CONF_SHOWFMT"%zu\n", "nch1", mp->nch1);
   if(up->nch2set)
-    fprintf(fp, CONF_SHOWFMT"%lu\n", "nch2", mp->nch2);
+    fprintf(fp, CONF_SHOWFMT"%zu\n", "nch2", mp->nch2);
   if(up->lastmeshfracset)
     fprintf(fp, CONF_SHOWFMT"%.3f\n", "lastmeshfrac", mp->lastmeshfrac);
   if(up->mirrordistset)
@@ -306,9 +306,9 @@ printvalues(FILE *fp, struct subtractskyparams *p)
   if(up->minmodeqset)
     fprintf(fp, CONF_SHOWFMT"%.3f\n", "minmodeq", mp->minmodeq);
   if(up->numnearestset)
-    fprintf(fp, CONF_SHOWFMT"%lu\n", "numnearest", mp->numnearest);
+    fprintf(fp, CONF_SHOWFMT"%zu\n", "numnearest", mp->numnearest);
   if(up->smoothwidthset)
-    fprintf(fp, CONF_SHOWFMT"%lu\n", "smoothwidth", mp->smoothwidth);
+    fprintf(fp, CONF_SHOWFMT"%zu\n", "smoothwidth", mp->smoothwidth);
   if(up->fullconvolutionset)
     fprintf(fp, CONF_SHOWFMT"%d\n", "fullconvolution",
             mp->fullconvolution);
@@ -456,7 +456,7 @@ sanitycheck(struct subtractskyparams *p)
   /* Other checks: */
   if(p->mp.numnearest<GAL_MESH_MIN_ACCEPTABLE_NEAREST)
     error(EXIT_FAILURE, 0, "the smallest possible number for "
-          "`--numnearest' (`-n') is %d. You have asked for: %lu",
+          "`--numnearest' (`-n') is %d. You have asked for: %zu",
           GAL_MESH_MIN_ACCEPTABLE_NEAREST, p->mp.numnearest);
 
   /* Set the constants in the gal_mesh_params structure. */
@@ -504,8 +504,8 @@ preparearrays(struct subtractskyparams *p)
   /* Check if the input sizes and channel sizes are exact
      multiples. */
   if( mp->s0%mp->nch2 || mp->s1%mp->nch1 )
-    error(EXIT_FAILURE, 0, "the input image size (%lu x %lu) is not an "
-          "exact multiple of the number of the given channels (%lu, %lu) "
+    error(EXIT_FAILURE, 0, "the input image size (%zu x %zu) is not an "
+          "exact multiple of the number of the given channels (%zu, %zu) "
           "in the respective axis", mp->s1, mp->s0, mp->nch1, mp->nch2);
 }
 
@@ -567,7 +567,7 @@ setparams(int argc, char *argv[], struct subtractskyparams 
*p)
   if(cp->verb)
     {
       printf(SPACK_NAME" started on %s", ctime(&p->rawtime));
-      printf("  - Using %lu CPU threads.\n", p->cp.numthreads);
+      printf("  - Using %zu CPU threads.\n", p->cp.numthreads);
       printf("  - Input: %s (hdu: %s)\n", p->up.inputname, p->cp.hdu);
       if(p->up.maskname)
         printf("  - Mask: %s (hdu: %s)\n", p->up.maskname, p->up.mhdu);
diff --git a/bin/table/table.c b/bin/table/table.c
index d00e6d1..0678de7 100644
--- a/bin/table/table.c
+++ b/bin/table/table.c
@@ -56,51 +56,51 @@ setformatstring(struct tableparams *p, size_t outcolid)
 
     case TBYTE:
       type="u";
-      sprintf(width, "%lu", up->sintwidth);
+      sprintf(width, "%zu", up->sintwidth);
       accu[0]='\0';
       break;
 
     case TLOGICAL: case TSBYTE:
       type="d";
-      sprintf(width, "%lu", up->sintwidth);
+      sprintf(width, "%zu", up->sintwidth);
       accu[0]='\0';
       break;
 
     case TSTRING:
       type="s";
-      if(up->sintwidth) sprintf(width, "%lu", up->sintwidth);
+      if(up->sintwidth) sprintf(width, "%zu", up->sintwidth);
       else width[0]='\0';
       accu[0]='\0';
       break;
 
     case TSHORT:
       type="d";
-      sprintf(width, "%lu", up->sintwidth);
+      sprintf(width, "%zu", up->sintwidth);
       accu[0]='\0';
       break;
 
     case TLONG:
       type="ld";
-      sprintf(width, "%lu", up->lintwidth);
+      sprintf(width, "%zu", up->lintwidth);
       accu[0]='\0';
       break;
 
     case TLONGLONG:
       type="ld";
-      sprintf(width, "%lu", up->lintwidth);
+      sprintf(width, "%zu", up->lintwidth);
       accu[0]='\0';
       break;
 
     case TFLOAT:
       type = up->feg=='f' ? "f" : ( up->feg=='e' ? "e" : "g");
-      sprintf(width, "%lu", up->floatwidth);
-      sprintf(accu, ".%lu", up->floatprecision);
+      sprintf(width, "%zu", up->floatwidth);
+      sprintf(accu, ".%zu", up->floatprecision);
       break;
 
     case TDOUBLE:
       type = up->feg=='f' ? "f" : ( up->feg=='e' ? "e" : "g");
-      sprintf(width, "%lu", up->doublewidth);
-      sprintf(accu, ".%lu", up->doubleprecision);
+      sprintf(width, "%zu", up->doublewidth);
+      sprintf(accu, ".%zu", up->doubleprecision);
       break;
 
     case TCOMPLEX:
@@ -117,25 +117,25 @@ setformatstring(struct tableparams *p, size_t outcolid)
 
     case TINT:
       type="d";
-      sprintf(width, "%lu", up->sintwidth);
+      sprintf(width, "%zu", up->sintwidth);
       accu[0]='\0';
       break;
 
     case TUINT:
       type="u";
-      sprintf(width, "%lu", up->sintwidth);
+      sprintf(width, "%zu", up->sintwidth);
       accu[0]='\0';
       break;
 
     case TUSHORT:
       type="u";
-      sprintf(width, "%lu", up->sintwidth);
+      sprintf(width, "%zu", up->sintwidth);
       accu[0]='\0';
       break;
 
     case TULONG:
       type="lu";
-      sprintf(width, "%lu", up->lintwidth);
+      sprintf(width, "%zu", up->lintwidth);
       accu[0]='\0';
       break;
 
@@ -197,7 +197,7 @@ readinputcols(struct tableparams *p)
           colfromtxt=col->data=malloc(nrows * sizeof *col->data);
 
           if(col->data==NULL)
-            error(EXIT_FAILURE, errno, "%lu bytes for col->data",
+            error(EXIT_FAILURE, errno, "%zu bytes for col->data",
                   nrows * sizeof *col->data);
           for(j=0;j<nrows;++j)
             colfromtxt[j]=p->up.txtarray[ j * incols + col->inindex ];
@@ -247,17 +247,17 @@ saveouttofits(struct tableparams *p)
   errno=0;
   ttype=malloc(p->nocols*sizeof *ttype);
   if(ttype==NULL)
-    error(EXIT_FAILURE, errno, "%lu bytes for ttype",
+    error(EXIT_FAILURE, errno, "%zu bytes for ttype",
           p->nocols*sizeof *ttype);
   errno=0;
   tform=malloc(p->nocols*sizeof *tform);
   if(tform==NULL)
-    error(EXIT_FAILURE, errno, "%lu bytes for tform",
+    error(EXIT_FAILURE, errno, "%zu bytes for tform",
           p->nocols*sizeof *tform);
   errno=0;
   tunit=malloc(p->nocols*sizeof *tunit);
   if(tunit==NULL)
-    error(EXIT_FAILURE, errno, "%lu bytes for tunit",
+    error(EXIT_FAILURE, errno, "%zu bytes for tunit",
           p->nocols*sizeof *tunit);
 
   /* Fill in the information arrays: */
diff --git a/bin/table/ui.c b/bin/table/ui.c
index 531da86..72b4262 100644
--- a/bin/table/ui.c
+++ b/bin/table/ui.c
@@ -137,7 +137,7 @@ readconfig(char *filename, struct tableparams *p)
   errno=0;
   line=malloc(len*sizeof *line);
   if(line==NULL)
-    error(EXIT_FAILURE, errno, "ui.c: %lu bytes in readdefaults",
+    error(EXIT_FAILURE, errno, "ui.c: %zu bytes in readdefaults",
           len * sizeof *line);
 
   /* Read the tokens in the file:  */
@@ -295,19 +295,19 @@ printvalues(FILE *fp, struct tableparams *p)
   if(up->fegset)
     fprintf(fp, CONF_SHOWFMT"%c\n", "feg", up->feg);
   if(up->sintwidthset)
-    fprintf(fp, CONF_SHOWFMT"%lu\n", "sintwidth", up->sintwidth);
+    fprintf(fp, CONF_SHOWFMT"%zu\n", "sintwidth", up->sintwidth);
   if(up->lintwidthset)
-    fprintf(fp, CONF_SHOWFMT"%lu\n", "lintwidth", up->lintwidth);
+    fprintf(fp, CONF_SHOWFMT"%zu\n", "lintwidth", up->lintwidth);
   if(up->floatwidthset)
-    fprintf(fp, CONF_SHOWFMT"%lu\n", "floatwidth", up->floatwidth);
+    fprintf(fp, CONF_SHOWFMT"%zu\n", "floatwidth", up->floatwidth);
   if(up->doublewidthset)
-    fprintf(fp, CONF_SHOWFMT"%lu\n", "doublewidth", up->doublewidth);
+    fprintf(fp, CONF_SHOWFMT"%zu\n", "doublewidth", up->doublewidth);
   if(up->strwidthset)
-    fprintf(fp, CONF_SHOWFMT"%lu\n", "strwidth", up->strwidth);
+    fprintf(fp, CONF_SHOWFMT"%zu\n", "strwidth", up->strwidth);
   if(up->floatprecisionset)
-    fprintf(fp, CONF_SHOWFMT"%lu\n", "floatprecision", up->floatprecision);
+    fprintf(fp, CONF_SHOWFMT"%zu\n", "floatprecision", up->floatprecision);
   if(up->doubleprecisionset)
-    fprintf(fp, CONF_SHOWFMT"%lu\n", "doubleprecision", up->doubleprecision);
+    fprintf(fp, CONF_SHOWFMT"%zu\n", "doubleprecision", up->doubleprecision);
   if(up->fitstabletypeset)
     fprintf(fp, CONF_SHOWFMT"%s\n", "fitstabletype",
             p->fitstabletype==ASCII_TBL ? "ascii" : "binary");
@@ -405,14 +405,14 @@ allocinputcolinfo(struct tableparams *p)
   errno=0;
   up->datatype=malloc(ncols * sizeof *up->datatype);
   if(up->datatype==NULL)
-    error(EXIT_FAILURE, errno, "%lu bytes for up->datatype",
+    error(EXIT_FAILURE, errno, "%zu bytes for up->datatype",
           ncols * sizeof *up->datatype);
 
   /* up->ttstr keeps the actual string used to specify the datatype. */
   errno=0;
   up->ttstr=malloc(ncols * sizeof *up->ttstr);
   if(up->ttstr==NULL)
-    error(EXIT_FAILURE, errno, "%lu bytes for ttstr",
+    error(EXIT_FAILURE, errno, "%zu bytes for ttstr",
           ncols * sizeof *up->ttstr);
   fc=(c=up->ttstr)+ncols; do *c++=NULL; while(c<fc);
 
@@ -420,7 +420,7 @@ allocinputcolinfo(struct tableparams *p)
   errno=0;
   up->tname=malloc(ncols * sizeof *up->tname);
   if(up->tname==NULL)
-    error(EXIT_FAILURE, errno, "%lu bytes for tname",
+    error(EXIT_FAILURE, errno, "%zu bytes for tname",
           ncols * sizeof *up->tname);
   fc=(c=up->tname)+ncols; do *c++=NULL; while(c<fc);
 
@@ -428,7 +428,7 @@ allocinputcolinfo(struct tableparams *p)
   errno=0;
   up->tunit=malloc(ncols * sizeof *up->tunit);
   if(up->tunit==NULL)
-    error(EXIT_FAILURE, errno, "%lu bytes for tunit",
+    error(EXIT_FAILURE, errno, "%zu bytes for tunit",
           ncols * sizeof *up->tunit);
   fc=(c=up->tunit)+ncols; do *c++=NULL; while(c<fc);
 }
@@ -623,18 +623,18 @@ printinfo(struct tableparams *p)
           typestring="unsigned short";
           break;
         default:
-          error(EXIT_FAILURE, 0, "%d (from TFORM%lu='%c') is not a "
+          error(EXIT_FAILURE, 0, "%d (from TFORM%zu='%c') is not a "
                 "recognized CFITSIO datatype.", up->datatype[i],
                 i, up->ttstr[i][0]);
         }
-      printf("%-5lu%-25s%-15s%s\n", i+1, up->tname[i] ? up->tname[i] : "---",
+      printf("%-5zu%-25s%-15s%s\n", i+1, up->tname[i] ? up->tname[i] : "---",
              up->tunit[i] ? up->tunit[i] : "---", typestring);
     }
 
 
   /* Print the number of rows: */
   printf("---------------------------------------------------------\n");
-  printf("Number of rows: %lu\n", p->nrows);
+  printf("Number of rows: %zu\n", p->nrows);
 }
 
 
@@ -750,7 +750,7 @@ regexerrorexit(int errcode, regex_t *compiled, char *input)
   errno=0;
   regexerrbuf=malloc(length);
   if(regexerrbuf==NULL)
-    error(EXIT_FAILURE, errno, "%lu bytes for regexerrbuf", length);
+    error(EXIT_FAILURE, errno, "%zu bytes for regexerrbuf", length);
   (void) regerror(errcode, compiled, regexerrbuf, length);
 
   error(EXIT_FAILURE, 0, "Regular expression error: %s in value to "
@@ -801,8 +801,8 @@ outputcolumns(struct tableparams *p)
           /* Check if the given value is not larger than the number of
              columns in the input catalog. */
           if(tlong>up->ncols)
-            error(EXIT_FAILURE, 0, "%s (hdu: %s) has %lu columns, but "
-                  "you have asked for column number %lu", p->up.fitsname,
+            error(EXIT_FAILURE, 0, "%s (hdu: %s) has %zu columns, but "
+                  "you have asked for column number %zu", p->up.fitsname,
                   p->cp.hdu, up->ncols, tlong);
 
           /* Everything seems to be fine, put this column number in the
@@ -815,7 +815,7 @@ outputcolumns(struct tableparams *p)
           /* Allocate the regex_t structure: */
           errno=0; regex=malloc(sizeof *regex);
           if(regex==NULL)
-            error(EXIT_FAILURE, errno, "%lu bytes for regex", sizeof *regex);
+            error(EXIT_FAILURE, errno, "%zu bytes for regex", sizeof *regex);
 
           /* Go through all the columns names and see if this matches
              them. But first we have to "compile" the string into the
@@ -860,7 +860,7 @@ outputcolumns(struct tableparams *p)
   errno=0;
   p->ocols=malloc(p->nocols*sizeof *p->ocols);
   if(p->ocols==NULL)
-    error(EXIT_FAILURE, errno, "%lu bytes for p->ocols",
+    error(EXIT_FAILURE, errno, "%zu bytes for p->ocols",
           p->nocols*sizeof *p->ocols);
 
   /* Fill in the output column with the needed input table
@@ -901,7 +901,7 @@ preparearrays(struct tableparams *p)
       errno=0;
       p->ocols=malloc(p->nocols * sizeof *p->ocols);
       if(p->ocols==NULL)
-        error(EXIT_FAILURE, errno, "%lu bytes for p->ocols",
+        error(EXIT_FAILURE, errno, "%zu bytes for p->ocols",
               p->nocols * sizeof *p->ocols);
       for(i=0;i<p->nocols;++i)
         {
diff --git a/doc/gnuastro.texi b/doc/gnuastro.texi
index cc6feb0..889b85c 100644
--- a/doc/gnuastro.texi
+++ b/doc/gnuastro.texi
@@ -16610,7 +16610,7 @@ main (void)
   float address@hidden,0.2,1.8,address@hidden;
   gal_qsort_index_arr=f;
   qsort(s, 4, sizeof(size_t), gal_qsort_index_float_decreasing);
-  printf("%lu, %lu, %lu, %lu\n", s[0], s[1], s[2], s[3]);
+  printf("%zu, %zu, %zu, %zu\n", s[0], s[1], s[2], s[3]);
   return EXIT_SUCCESS;
 @}
 @end example
diff --git a/lib/array.c b/lib/array.c
index e7334fd..301286a 100644
--- a/lib/array.c
+++ b/lib/array.c
@@ -116,7 +116,7 @@ gal_array_uchar_copy(unsigned char *in, size_t size, 
unsigned char **out)
   errno=0;
   o=*out=malloc(size*sizeof *out);
   if(*out==NULL)
-    error(EXIT_FAILURE, errno, "%lu bytes for copying", size);
+    error(EXIT_FAILURE, errno, "%zu bytes for copying", size);
   do *o++=*in; while(++in<fp);
 }
 
@@ -132,7 +132,7 @@ gal_array_float_copy(float *in, size_t size, float **out)
   errno=0;
   o=*out=malloc(size*sizeof *out);
   if(*out==NULL)
-    error(EXIT_FAILURE, errno, "%lu bytes for copying", size);
+    error(EXIT_FAILURE, errno, "%zu bytes for copying", size);
   do *o++=*in; while(++in<fp);
 }
 
@@ -327,7 +327,7 @@ gal_array_fsum_arrays(float *in1, float *in2, size_t size)
   errno=0;
   o=out=malloc(size*sizeof *out);
   if(out==NULL)
-    error(EXIT_FAILURE, errno, "%lu bytes for out in gal_array_fsum_arrays"
+    error(EXIT_FAILURE, errno, "%zu bytes for out in gal_array_fsum_arrays"
           " (array.c)", size*sizeof *out);
 
   op=o+size;
diff --git a/lib/checkset.c b/lib/checkset.c
index a09df17..0a309a7 100644
--- a/lib/checkset.c
+++ b/lib/checkset.c
@@ -583,7 +583,7 @@ gal_checkset_malloc_cat(char *inname, char *toappend)
   out=malloc(inl+apl+1);
   if(out==NULL)
     error(EXIT_FAILURE, errno,
-          "allocating %lu bytes in gal_checkset_malloc_cat", inl+apl+1);
+          "allocating %zu bytes in gal_checkset_malloc_cat", inl+apl+1);
 
   strcpy(out, inname);
   strcat(out, toappend);
@@ -602,7 +602,7 @@ gal_checkset_allocate_copy(char *arg, char **copy)
   errno=0;
   *copy=malloc(strlen(arg)+1);
   if(*copy==NULL)
-    error(EXIT_FAILURE, errno, "%lu bytes to copy %s",
+    error(EXIT_FAILURE, errno, "%zu bytes to copy %s",
           strlen(arg)+1, arg);
   strcpy(*copy, arg);
 }
@@ -624,7 +624,7 @@ gal_checkset_allocate_copy_set(char *arg, char **copy, int 
*set)
   errno=0;
   *copy=malloc(strlen(arg)+1);
   if(*copy==NULL)
-    error(EXIT_FAILURE, errno, "%lu bytes to copy %s",
+    error(EXIT_FAILURE, errno, "%zu bytes to copy %s",
           strlen(arg)+1, arg);
   strcpy(*copy, arg);
   *set=1;
@@ -892,7 +892,7 @@ gal_checkset_dir_part(char *input)
       errno=0;
       out=malloc(3*sizeof *out);
       if(out==NULL)
-        error(EXIT_FAILURE, errno, "%lu bytes for current directory "
+        error(EXIT_FAILURE, errno, "%zu bytes for current directory "
               "gal_checkset_dir_part", 3*sizeof *out);
       strcpy(out, "./");
     }
@@ -901,7 +901,7 @@ gal_checkset_dir_part(char *input)
       errno=0;
       out=malloc((l+1)*sizeof *out);
       if(out==NULL)
-        error(EXIT_FAILURE, errno, "%lu bytes for gal_checkset_dir_part",
+        error(EXIT_FAILURE, errno, "%zu bytes for gal_checkset_dir_part",
               (l+1)*sizeof *out);
       strcpy(out, input);
       out[i+1]='\0';
@@ -934,7 +934,7 @@ gal_checkset_not_dir_part(char *input)
   errno=0;
   out=malloc((l+1)*sizeof *out);
   if(out==NULL)
-    error(EXIT_FAILURE, errno, "%lu bytes for notdir", (l+1)*sizeof *out);
+    error(EXIT_FAILURE, errno, "%zu bytes for notdir", (l+1)*sizeof *out);
 
   strcpy(out, tmp);
   return out;
diff --git a/lib/checkset.h b/lib/checkset.h
index a6e3d77..7954a7e 100644
--- a/lib/checkset.h
+++ b/lib/checkset.h
@@ -55,8 +55,8 @@ __BEGIN_C_DECLS  /* From C++ preparations */
 /* Check if the column number is within the boundaries of a catalog. */
 #define GAL_CHECKSET_CHECK_COL_NUM_IN_CAT(INCOL,NAME) {                 \
     if( (INCOL) >= p->cs1 )                                             \
-      error(EXIT_FAILURE, 0, "%s only has %lu columns while you "       \
-            "have requested column %lu (counting from zero) for "       \
+      error(EXIT_FAILURE, 0, "%s only has %zu columns while you "       \
+            "have requested column %zu (counting from zero) for "       \
             "`--%s`", p->up.catname, p->cs1, (INCOL), (NAME));          \
   }
 
@@ -70,13 +70,13 @@ __BEGIN_C_DECLS  /* From C++ preparations */
     size_t i;                                                           \
                                                                         \
     if( (INCOL) >= p->cs1 )                                             \
-      error(EXIT_FAILURE, 0, "%s only has %lu columns while you "       \
-            "have requested column %lu (counting from zero) for "       \
+      error(EXIT_FAILURE, 0, "%s only has %zu columns while you "       \
+            "have requested column %zu (counting from zero) for "       \
             "`--%s`", p->up.catname, p->cs1, (INCOL), (NAME));          \
                                                                         \
     for(i=0;i<p->cs0;++i)                                               \
       if( !isfinite(p->cat[i*p->cs1+(INCOL)]) )                         \
-        error(EXIT_FAILURE, 0, "%s: column %lu (--%s) in row %lu "      \
+        error(EXIT_FAILURE, 0, "%s: column %zu (--%s) in row %zu "      \
               "could not be read as a number. See %s. Note that "       \
               "counting starts from zero",                              \
               p->up.catname, (INCOL), (NAME), i, GAL_TXTARRAY_LOG);     \
diff --git a/lib/configfiles.h b/lib/configfiles.h
index 3cfc1d3..09db2f6 100644
--- a/lib/configfiles.h
+++ b/lib/configfiles.h
@@ -222,7 +222,7 @@ __BEGIN_C_DECLS  /* From C++ preparations */
 /* Write common options: */
 #define GAL_CONFIGFILES_PRINT_COMMONOPTIONS {                           \
     if(cp->numthreadsset)                                               \
-      fprintf(fp, CONF_SHOWFMT"%lu\n", "numthreads", p->cp.numthreads); \
+      fprintf(fp, CONF_SHOWFMT"%zu\n", "numthreads", p->cp.numthreads); \
     if(cp->nologset)                                                    \
       fprintf(fp, CONF_SHOWFMT"%d\n", "nolog", p->cp.nolog);            \
     if(cp->onlyversionset)                                              \
diff --git a/lib/fits.c b/lib/fits.c
index 730b7bb..ba024db 100644
--- a/lib/fits.c
+++ b/lib/fits.c
@@ -267,7 +267,7 @@ gal_fits_datatype_blank(int datatype)
     case TBYTE:
       b=malloc(sizeof *b);
       if(b==NULL)
-        error(EXIT_FAILURE, errno, "%lu bytes for blank TBYTE",
+        error(EXIT_FAILURE, errno, "%zu bytes for blank TBYTE",
               sizeof *b);
       *b=GAL_FITS_BYTE_BLANK;
       return b;
@@ -278,7 +278,7 @@ gal_fits_datatype_blank(int datatype)
     case TLOGICAL: case TSBYTE:
       c=malloc(sizeof *c);
       if(c==NULL)
-        error(EXIT_FAILURE, errno, "%lu bytes for blank TLOGICAL, or TSBYTE",
+        error(EXIT_FAILURE, errno, "%zu bytes for blank TLOGICAL, or TSBYTE",
               sizeof *c);
       *c=GAL_FITS_LOGICAL_BLANK;
       return c;
@@ -286,7 +286,7 @@ gal_fits_datatype_blank(int datatype)
     case TSTRING:
       str=malloc(sizeof *str);
       if(str==NULL)
-        error(EXIT_FAILURE, errno, "%lu bytes for blank TSTRING",
+        error(EXIT_FAILURE, errno, "%zu bytes for blank TSTRING",
               sizeof *s);
       *str=GAL_FITS_STRING_BLANK;
       return str;
@@ -294,7 +294,7 @@ gal_fits_datatype_blank(int datatype)
     case TSHORT:
       s=malloc(sizeof *s);
       if(s==NULL)
-        error(EXIT_FAILURE, errno, "%lu bytes for blank TSHORT",
+        error(EXIT_FAILURE, errno, "%zu bytes for blank TSHORT",
               sizeof *s);
       *s=GAL_FITS_SHORT_BLANK;
       return s;
@@ -302,7 +302,7 @@ gal_fits_datatype_blank(int datatype)
     case TLONG:
       l=malloc(sizeof *l);
       if(l==NULL)
-        error(EXIT_FAILURE, errno, "%lu bytes for blank TLONG",
+        error(EXIT_FAILURE, errno, "%zu bytes for blank TLONG",
               sizeof *l);
       *l=GAL_FITS_LONG_BLANK;
       return l;
@@ -310,7 +310,7 @@ gal_fits_datatype_blank(int datatype)
     case TLONGLONG:
       L=malloc(sizeof *L);
       if(L==NULL)
-        error(EXIT_FAILURE, errno, "%lu bytes for blank TLONGLONG",
+        error(EXIT_FAILURE, errno, "%zu bytes for blank TLONGLONG",
               sizeof *L);
       *L=GAL_FITS_LLONG_BLANK;
       return L;
@@ -318,7 +318,7 @@ gal_fits_datatype_blank(int datatype)
     case TFLOAT:
       f=malloc(sizeof *f);
       if(f==NULL)
-        error(EXIT_FAILURE, errno, "%lu bytes for blank TFLOAT",
+        error(EXIT_FAILURE, errno, "%zu bytes for blank TFLOAT",
               sizeof *f);
       *f=GAL_FITS_FLOAT_BLANK;
       return f;
@@ -326,7 +326,7 @@ gal_fits_datatype_blank(int datatype)
     case TDOUBLE:
       d=malloc(sizeof *d);
       if(d==NULL)
-        error(EXIT_FAILURE, errno, "%lu bytes for blank TDOUBLE",
+        error(EXIT_FAILURE, errno, "%zu bytes for blank TDOUBLE",
               sizeof *d);
       *d=GAL_FITS_DOUBLE_BLANK;
       return d;
@@ -334,7 +334,7 @@ gal_fits_datatype_blank(int datatype)
     case TCOMPLEX:
       cx=malloc(sizeof *cx);
       if(cx==NULL)
-        error(EXIT_FAILURE, errno, "%lu bytes for blank TCOMPLEX",
+        error(EXIT_FAILURE, errno, "%zu bytes for blank TCOMPLEX",
               sizeof *cx);
       GSL_SET_COMPLEX(cx,GAL_FITS_FLOAT_BLANK,GAL_FITS_FLOAT_BLANK);
       return cx;
@@ -342,7 +342,7 @@ gal_fits_datatype_blank(int datatype)
     case TDBLCOMPLEX:
       dcx=malloc(sizeof *dcx);
       if(dcx==NULL)
-        error(EXIT_FAILURE, errno, "%lu bytes for blank TDBLCOMPLEX",
+        error(EXIT_FAILURE, errno, "%zu bytes for blank TDBLCOMPLEX",
               sizeof *dcx);
       GSL_SET_COMPLEX(dcx,GAL_FITS_DOUBLE_BLANK,GAL_FITS_DOUBLE_BLANK);
       return dcx;
@@ -350,7 +350,7 @@ gal_fits_datatype_blank(int datatype)
     case TINT:
       i=malloc(sizeof *i);
       if(i==NULL)
-        error(EXIT_FAILURE, errno, "%lu bytes for blank TINT",
+        error(EXIT_FAILURE, errno, "%zu bytes for blank TINT",
               sizeof *i);
       *i=GAL_FITS_INT_BLANK;
       return i;
@@ -358,7 +358,7 @@ gal_fits_datatype_blank(int datatype)
     case TUINT:
       ui=malloc(sizeof *ui);
       if(ui==NULL)
-        error(EXIT_FAILURE, errno, "%lu bytes for blank TUINT",
+        error(EXIT_FAILURE, errno, "%zu bytes for blank TUINT",
               sizeof *ui);
       *ui=GAL_FITS_UINT_BLANK;
       return ui;
@@ -366,7 +366,7 @@ gal_fits_datatype_blank(int datatype)
     case TUSHORT:
       us=malloc(sizeof *us);
       if(us==NULL)
-        error(EXIT_FAILURE, errno, "%lu bytes for blank TUSHORT",
+        error(EXIT_FAILURE, errno, "%zu bytes for blank TUSHORT",
               sizeof *us);
       *us=GAL_FITS_USHORT_BLANK;
       return us;
@@ -374,7 +374,7 @@ gal_fits_datatype_blank(int datatype)
     case TULONG:
       ul=malloc(sizeof *ul);
       if(ul==NULL)
-        error(EXIT_FAILURE, errno, "%lu bytes for blank TULONG",
+        error(EXIT_FAILURE, errno, "%zu bytes for blank TULONG",
               sizeof *ul);
       *ul=GAL_FITS_ULONG_BLANK;
       return ul;
@@ -493,7 +493,7 @@ gal_fits_datatype_alloc(size_t size, int datatype)
   array=malloc(size);
   if(array==NULL)
     error(EXIT_FAILURE, errno,
-          "array of %lu bytes in gal_fits_datatype_alloc", size);
+          "array of %zu bytes in gal_fits_datatype_alloc", size);
 
   return array;
 }
@@ -1047,7 +1047,7 @@ gal_fits_read_hdu(char *filename, char *hdu, unsigned 
char img0_tab1,
   len=strlen(filename)+strlen(hdu)+4;
   ffname=malloc(len*sizeof *ffname);
   if(ffname==NULL)
-    error(EXIT_FAILURE, errno, "%lu characters", len);
+    error(EXIT_FAILURE, errno, "%zu characters", len);
   sprintf(ffname, "%s[%s#]", filename, hdu);
 
   /* Open the FITS file: */
@@ -1112,7 +1112,7 @@ gal_fits_read_keywords(char *filename, char *hdu, struct 
gal_fits_key *keys,
   len=strlen(filename)+strlen(hdu)+4;
   ffname=malloc(len*sizeof *ffname);
   if(ffname==NULL)
-    error(EXIT_FAILURE, errno, "%lu characters", len);
+    error(EXIT_FAILURE, errno, "%zu characters", len);
   sprintf(ffname, "%s[%s#]", filename, hdu);
 
   /* Open the FITS file: */
@@ -1150,7 +1150,7 @@ gal_fits_read_keywords(char *filename, char *hdu, struct 
gal_fits_key *keys,
           valueptr=&keys[i].d;
           break;
         default:
-          error(EXIT_FAILURE, 0, "the value of keys[%lu].datatype (=%d) "
+          error(EXIT_FAILURE, 0, "the value of keys[%zu].datatype (=%d) "
                 "is not recognized", i, keys[i].datatype);
         }
 
@@ -1301,14 +1301,14 @@ gal_fits_file_name_in_keywords(char *keynamebase, char 
*filename,
       keyname=malloc(FLEN_KEYWORD);
       if(keyname==NULL)
         error(EXIT_FAILURE, errno, "%d bytes", FLEN_KEYWORD);
-      sprintf(keyname, "%s_%lu", keynamebase, numkey++);
+      sprintf(keyname, "%s_%zu", keynamebase, numkey++);
 
       /* Set the keyword value: */
       errno=0;
       thislen=strlen(&filename[i]);
       value=malloc(maxlength);
       if(value==NULL)
-        error(EXIT_FAILURE, errno, "%lu bytes", thislen);
+        error(EXIT_FAILURE, errno, "%zu bytes", thislen);
       strncpy(value, &filename[i], maxlength);
 
       /* If the FROM string (=&filename[i]) in strncpy is shorter than
@@ -1334,7 +1334,7 @@ gal_fits_file_name_in_keywords(char *keynamebase, char 
*filename,
               }
           if(j==0)
             error(EXIT_FAILURE, 0, "the filename `%sP has at least one "
-                  "span of %lu characters without a `/`. It cannot be "
+                  "span of %zu characters without a `/`. It cannot be "
                   "written to the header of the output fits file",
                   filename, maxlength);
 
@@ -2014,7 +2014,7 @@ gal_fits_file_to_float(char *inputname, char *maskname, 
char *inhdu,
 
       if(s0!=*ins0 || s1!=*ins1)
         error(EXIT_FAILURE, 0, "the input image %s (hdu: %s) has size: "
-              "%lu x %lu. The mask image %s (hdu: %s) has size %lu x %lu. "
+              "%zu x %zu. The mask image %s (hdu: %s) has size %zu x %zu. "
               "The two images have to have the same size", inputname,
               inhdu, *ins1, *ins0, maskname, mhdu, s1, s0);
 
@@ -2079,7 +2079,7 @@ gal_fits_file_to_double(char *inputname, char *maskname, 
char *inhdu,
 
       if(s0!=*ins0 || s1!=*ins1)
         error(EXIT_FAILURE, 0, "the input image %s (hdu: %s) has size: "
-              "%lu x %lu. The mask image %s (hdu: %s) has size %lu x %lu. "
+              "%zu x %zu. The mask image %s (hdu: %s) has size %zu x %zu. "
               "The two images have to have the same size", inputname,
               inhdu, *ins1, *ins0, maskname, mhdu, s1, s0);
 
@@ -2147,7 +2147,7 @@ gal_fits_prep_float_kernel(char *inputname, char *inhdu, 
float **outkernel,
   if(*ins0%2==0 || *ins1%2==0)
     error(EXIT_FAILURE, 0, "the kernel image has to have an odd number "
           "of pixels on both sides (there has to be on pixel in the "
-          "center). %s (hdu: %s) is %lu by %lu", inputname, inhdu,
+          "center). %s (hdu: %s) is %zu by %zu", inputname, inhdu,
           *ins1, *ins0);
 
   /* If there are any NaN pixels, set them to zero and normalize it.*/
diff --git a/lib/git.c b/lib/git.c
index a9babdd..92064f4 100644
--- a/lib/git.c
+++ b/lib/git.c
@@ -63,7 +63,7 @@ gal_git_describe(void)
       errno=0;
       describe_return=malloc(strlen(buf.ptr)+1);
       if(describe_return==NULL)
-        error(EXIT_FAILURE, errno, "%lu bytes to copy Git's describe",
+        error(EXIT_FAILURE, errno, "%zu bytes to copy Git's describe",
               strlen(buf.ptr)+1);
       strcpy(describe_return, buf.ptr);
     }
diff --git a/lib/linkedlist.c b/lib/linkedlist.c
index 847583d..b09df81 100644
--- a/lib/linkedlist.c
+++ b/lib/linkedlist.c
@@ -48,7 +48,7 @@ gal_linkedlist_print_fll_array(struct gal_linkedlist_fll 
**afll, size_t num)
   struct gal_linkedlist_fll *tmp;
   for(i=0;i<num;++i)
     {
-      printf(" %lu:\n", i);
+      printf(" %zu:\n", i);
       for(tmp=afll[i];tmp!=NULL;tmp=tmp->next)
         printf("%f, ", tmp->v);
       printf("\n");
@@ -124,7 +124,7 @@ gal_linkedlist_fll_to_array(struct gal_linkedlist_fll *list,
   *f=malloc(*num*sizeof(float));
   if(*f==NULL)
     error(EXIT_FAILURE, errno, "linkedlist: array of gal_linkedlist_fll "
-          "with %lu elements", *num);
+          "with %zu elements", *num);
   tf=*f;
 
   /* Fill in the array: */
@@ -254,7 +254,7 @@ gal_linkedlist_tdll_to_array_inv(struct gal_linkedlist_tdll 
*list,
   td=*d=malloc(2 * *num * sizeof(double));
   if(*d==NULL)
     error(EXIT_FAILURE, errno, "linkedlist: array of gal_linkedlist_tdll "
-          "with %lu elements", *num);
+          "with %zu elements", *num);
 
   /* Fill in the array in reverse order */
   i = 2 * *num - 2;
@@ -457,7 +457,7 @@ gal_linkedlist_sll_to_array(struct gal_linkedlist_sll *list,
   *s=malloc(*num*sizeof(size_t));
   if(*s==NULL)
     error(EXIT_FAILURE, errno, "linkedlist: array of gal_linkedlist_sll "
-          "with %lu elements", *num);
+          "with %zu elements", *num);
   ts=*s;
 
   i = inverse ? *num-1: 0;
@@ -479,7 +479,7 @@ gal_linkedlist_print_sll(struct gal_linkedlist_sll *list)
   struct gal_linkedlist_sll *tmp;
   printf("\n\n");
   for(tmp=list;tmp!=NULL;tmp=tmp->next)
-    printf("%lu, ", tmp->v);
+    printf("%zu, ", tmp->v);
   printf("\b\b.\n\n");
   return;
 }
@@ -643,10 +643,10 @@ gal_linkedlist_print_tosll(struct gal_linkedlist_tosll 
*largest,
   size_t counter=1;   /* We are not counting array elements :-D ! */
   while(largest!=NULL)
     {
-      printf("\t%-5lu (%lu, %.4f) \n", counter++,
+      printf("\t%-5zu (%zu, %.4f) \n", counter++,
              largest->v, largest->s);
       largest=largest->next;
-      printf("\t\t\t\t(%lu, %.4f)\n", smallest->v, smallest->s);
+      printf("\t\t\t\t(%zu, %.4f)\n", smallest->v, smallest->s);
       smallest=smallest->prev;
     }
   printf("\n");
@@ -730,7 +730,7 @@ gal_linkedlist_pop_from_tosll_start(struct 
gal_linkedlist_tosll **largest,
   else
     *largest=NULL;
 
-  /*printf("Popped v: %lu, s: %f\n", *value, *tosort);*/
+  /*printf("Popped v: %zu, s: %f\n", *value, *tosort);*/
 }
 
 
diff --git a/lib/mesh.c b/lib/mesh.c
index a8cc0e0..6d772e3 100644
--- a/lib/mesh.c
+++ b/lib/mesh.c
@@ -104,7 +104,7 @@ gal_mesh_ch_based_id_from_gid(struct gal_mesh_params *mp, 
size_t gid)
       size_t inchannelid = (f0%mp->gs0) * mp->gs1 + f1%mp->gs1;
 
       /* For a check:
-      printf("%lu:\n\t(f0, f1): (%lu, %lu)\t chid: %lu\tinchannelid: %lu\n",
+      printf("%zu:\n\t(f0, f1): (%zu, %zu)\t chid: %zu\tinchannelid: %zu\n",
              gid, f0, f1, chid, inchannelid);
       */
 
@@ -140,9 +140,9 @@ gal_mesh_gid_from_ch_based_id(struct gal_mesh_params *mp, 
size_t chbasedid)
       size_t my=(chbasedid%mp->nmeshc)%mp->gs1;
 
       /* For a check:
-      printf("%lu:\n\t(chx, chy): (%lu, %lu)"
-             "\n\t(mx, my): (%lu, %lu)"
-             "\n\t%lu\n\n",
+      printf("%zu:\n\t(chx, chy): (%zu, %zu)"
+             "\n\t(mx, my): (%zu, %zu)"
+             "\n\t%zu\n\n",
              chbasedid, chx, chy, mx, my,
              (chx*mp->gs0+mx) * mp->nch1 + (chy*mp->gs1+my));
       */
@@ -269,7 +269,7 @@ gal_mesh_full_garray(struct gal_mesh_params *mp, int 
reverse)
       /* Allocate the fgarrays */
       errno=0; mp->fgarray1=malloc(mp->nmeshi*sizeof *mp->fgarray1);
       if(mp->fgarray1==NULL)
-        error(EXIT_FAILURE, errno, "%lu bytes for mp->fgarray1 (mesh.c)",
+        error(EXIT_FAILURE, errno, "%zu bytes for mp->fgarray1 (mesh.c)",
               mp->nmeshi*sizeof *mp->fgarray1);
     }
   if(mp->ngarrays==2 && mp->fgarray2==NULL)
@@ -277,7 +277,7 @@ gal_mesh_full_garray(struct gal_mesh_params *mp, int 
reverse)
       errno=0;
       mp->fgarray2=malloc(mp->nmeshi*sizeof *mp->fgarray2);
       if(mp->fgarray2==NULL)
-        error(EXIT_FAILURE, errno, "%lu bytes for mp->fgarray2 (mesh.c)",
+        error(EXIT_FAILURE, errno, "%zu bytes for mp->fgarray2 (mesh.c)",
               mp->nmeshi*sizeof *mp->fgarray2);
     }
   fgarray1=mp->fgarray1;
@@ -398,14 +398,14 @@ gal_mesh_check_garray(struct gal_mesh_params *mp, float 
**out1,
   errno=0; *out1=malloc(mp->s0*mp->s1*sizeof **out1);
   if(*out1==NULL)
     error(EXIT_FAILURE, errno,
-          "%lu bytes for out1 in gal_mesh_check_garray (mesh.c)",
+          "%zu bytes for out1 in gal_mesh_check_garray (mesh.c)",
           mp->s0*mp->s1*sizeof **out1);
   if(ngarrays==2)
     {
       errno=0; *out2=malloc(mp->s0*mp->s1*sizeof **out2);
       if(*out2==NULL)
         error(EXIT_FAILURE, errno,
-              "%lu bytes for out2 in gal_mesh_check_garray (mesh.c)",
+              "%zu bytes for out2 in gal_mesh_check_garray (mesh.c)",
               mp->s0*mp->s1*sizeof **out2);
     }
 
@@ -859,7 +859,7 @@ gal_mesh_operate_on_mesh(struct gal_mesh_params *mp,
      thread. */
   errno=0; mtp=malloc(numthreads*sizeof *mtp);
   if(mtp==NULL)
-    error(EXIT_FAILURE, errno, "%lu bytes in fillmesh (mesh.c) for mtp",
+    error(EXIT_FAILURE, errno, "%zu bytes in fillmesh (mesh.c) for mtp",
           numthreads*sizeof *mtp);
 
   /* Set the number of garrays to operate on: */
@@ -906,7 +906,7 @@ gal_mesh_operate_on_mesh(struct gal_mesh_params *mp,
       errno=0;
       mp->oneforall=malloc(numthreads*mp->maxs0*mp->maxs1*oneforallsize);
       if(mp->oneforall==NULL)
-        error(EXIT_FAILURE, errno, "unable to allocate %lu bytes for"
+        error(EXIT_FAILURE, errno, "unable to allocate %zu bytes for"
               "mtp->oneforall in fillmesh of mesh.c",
               numthreads*mp->maxs0*mp->maxs1*oneforallsize);
     }
@@ -935,7 +935,7 @@ gal_mesh_operate_on_mesh(struct gal_mesh_params *mp,
             mtp[i].id=i;
             mtp[i].mp=mp;
             err=pthread_create(&t, &attr, meshfunc, &mtp[i]);
-            if(err) error(EXIT_FAILURE, 0, "can't create thread %lu", i);
+            if(err) error(EXIT_FAILURE, 0, "can't create thread %zu", i);
           }
 
       /* Wait for all threads to finish and free the spaces. */
@@ -1007,13 +1007,13 @@ preparemeshinterparrays(struct gal_mesh_params *mp)
      garrays. */
   errno=0; mp->outgarray1=malloc(mp->nmeshi*sizeof *mp->outgarray1);
   if(mp->outgarray1==NULL)
-    error(EXIT_FAILURE, errno, "%lu bytes for outgarray1 (mesh.c)",
+    error(EXIT_FAILURE, errno, "%zu bytes for outgarray1 (mesh.c)",
           mp->nmeshi*sizeof *mp->outgarray1);
   if(mp->ngarrays==2)
     {
       errno=0; mp->outgarray2=malloc(mp->nmeshi*sizeof *mp->outgarray2);
       if(mp->outgarray2==NULL)
-        error(EXIT_FAILURE, errno, "%lu bytes for outgarray2 (mesh.c)",
+        error(EXIT_FAILURE, errno, "%zu bytes for outgarray2 (mesh.c)",
               mp->nmeshi*sizeof *mp->outgarray2);
     }
 
@@ -1026,7 +1026,7 @@ preparemeshinterparrays(struct gal_mesh_params *mp)
   errno=0;
   mp->nearest1=malloc(numthreads*mp->numnearest*sizeof *mp->nearest1);
   if(mp->nearest1==NULL)
-    error(EXIT_FAILURE, errno, "%lu bytes for the array to keep the "
+    error(EXIT_FAILURE, errno, "%zu bytes for the array to keep the "
           "nearest1 values for interpolation (mesh.c)",
           numthreads*mp->numnearest*sizeof *mp->nearest1);
   if(mp->ngarrays==2)
@@ -1034,7 +1034,7 @@ preparemeshinterparrays(struct gal_mesh_params *mp)
       errno=0;
       mp->nearest2=malloc(numthreads*mp->numnearest*sizeof *mp->nearest2);
       if(mp->nearest2==NULL)
-        error(EXIT_FAILURE, errno, "%lu bytes for the array to keep the "
+        error(EXIT_FAILURE, errno, "%zu bytes for the array to keep the "
               "nearest2 values for interpolation (mesh.c)",
               numthreads*mp->numnearest*sizeof *mp->nearest2);
     }
@@ -1045,7 +1045,7 @@ preparemeshinterparrays(struct gal_mesh_params *mp)
      array. */
   errno=0; mp->byt=malloc(numthreads*bs0*bs1*sizeof *mp->byt);
   if(mp->byt==NULL)
-    error(EXIT_FAILURE, errno, "%lu bytes for mp->byt array in "
+    error(EXIT_FAILURE, errno, "%zu bytes for mp->byt array in "
           "mesh.c", numthreads*bs0*bs1*sizeof *mp->byt);
 }
 
@@ -1172,12 +1172,12 @@ meshinterponthread(void *inparams)
              interpolation. Normally, this loop should only be exited
              through the `currentnum>=numnearest' check above. */
           if(sQ==NULL)
-            error(EXIT_FAILURE, 0, "%s: only %lu mesh(s) are filled for "
-                  "interpolation in channel %lu. Either set less "
+            error(EXIT_FAILURE, 0, "%s: only %zu mesh(s) are filled for "
+                  "interpolation in channel %zu. Either set less "
                   "restrictive requirements to get more interpolation "
                   "points or decrease the number of nearest points to "
                   "use for interpolation. Problem encountered on thread "
-                  "%lu, for pixel %lu. When running on multiple threads, "
+                  "%zu, for pixel %zu. When running on multiple threads, "
                   "This message might be repeated for different threads",
                   mp->errstart, currentnum, thisind/mp->nmeshc, mtp->id,
                   thisind);
@@ -1232,7 +1232,7 @@ gal_mesh_interpolate(struct gal_mesh_params *mp, char 
*errstart)
      thread. */
   errno=0; mtp=malloc(numthreads*sizeof *mtp);
   if(mtp==NULL)
-    error(EXIT_FAILURE, errno, "%lu bytes in fillmesh (mesh.c) for mtp",
+    error(EXIT_FAILURE, errno, "%zu bytes in fillmesh (mesh.c) for mtp",
           numthreads*sizeof *mtp);
 
   /* Spin off the threads: */
@@ -1259,7 +1259,7 @@ gal_mesh_interpolate(struct gal_mesh_params *mp, char 
*errstart)
             mtp[i].id=i;
             mtp[i].mp=mp;
             err=pthread_create(&t, &attr, meshinterponthread, &mtp[i]);
-            if(err) error(EXIT_FAILURE, 0, "can't create thread %lu", i);
+            if(err) error(EXIT_FAILURE, 0, "can't create thread %zu", i);
           }
 
       /* Wait for all threads to finish and free the spaces. */
@@ -1333,7 +1333,7 @@ gal_mesh_smooth(struct gal_mesh_params *mp)
   errno=0;
   kernel=malloc(smoothwidth*smoothwidth*sizeof *kernel);
   if(kernel==NULL)
-    error(EXIT_FAILURE, errno, "%lu bytes for kernel in mesh.c",
+    error(EXIT_FAILURE, errno, "%zu bytes for kernel in mesh.c",
           mp->smoothwidth*sizeof *kernel);
   fp=(f=kernel)+smoothwidth*smoothwidth; do *f++=1; while(f<fp);
 
@@ -1546,14 +1546,14 @@ gal_mesh_spatial_convolve_on_mesh(struct 
gal_mesh_params *mp, float **conv)
      thread. */
   errno=0; mtp=malloc(numthreads*sizeof *mtp);
   if(mtp==NULL)
-    error(EXIT_FAILURE, errno, "%lu bytes in fillmesh (mesh.c) for mtp",
+    error(EXIT_FAILURE, errno, "%zu bytes in fillmesh (mesh.c) for mtp",
           numthreads*sizeof *mtp);
 
 
   /* Allocate space for the convolved array. */
   errno=0; *conv=malloc(mp->s0*mp->s1* sizeof **conv);
   if(*conv==NULL)
-    error(EXIT_FAILURE, errno, "%lu bytes for convolution on mesh output",
+    error(EXIT_FAILURE, errno, "%zu bytes for convolution on mesh output",
           mp->s0*mp->s1* sizeof **conv);
 
 
@@ -1568,7 +1568,7 @@ gal_mesh_spatial_convolve_on_mesh(struct gal_mesh_params 
*mp, float **conv)
   */
   errno=0; chbrd=malloc(mp->nch*4*sizeof *chbrd);
   if(chbrd==NULL)
-    error(EXIT_FAILURE, errno, "%lu bytes for chbrd in "
+    error(EXIT_FAILURE, errno, "%zu bytes for chbrd in "
           "gal_mesh_spatial_convolve_on_mesh", mp->nch*4*sizeof *chbrd);
   for(i=0;i<mp->nch;++i)
     {
@@ -1616,7 +1616,7 @@ gal_mesh_spatial_convolve_on_mesh(struct gal_mesh_params 
*mp, float **conv)
             mtp[i].conv=*conv;
             mtp[i].chbrd=chbrd;
             err=pthread_create(&t, &attr, meshspatialconvonthreads, &mtp[i]);
-            if(err) error(EXIT_FAILURE, 0, "can't create thread %lu", i);
+            if(err) error(EXIT_FAILURE, 0, "can't create thread %zu", i);
           }
 
       /* Wait for all threads to finish and free the spaces. */
@@ -1687,7 +1687,7 @@ corrconvindexs(struct gal_mesh_params *mp, size_t 
**indexs,
       ahigh = i*npch0+hk0>s0 ? s0 : i*npch0+hk0;
 
       /* For a check
-      printf("1: alow: %-4lu ahigh: %-4lu.\t(0 -- %lu)\n",
+      printf("1: alow: %-4zu ahigh: %-4zu.\t(0 -- %zu)\n",
              alow, ahigh, s1);
       */
       for(a=alow; a<ahigh; ++a)
@@ -1716,8 +1716,8 @@ corrconvindexs(struct gal_mesh_params *mp, size_t 
**indexs,
               ahigh = i*npch0<hk0    ? 0  : i*npch0-hk0;
 
               /* For a check:
-              printf("2: alow: %-4lu ahigh: %-4lu. b: %-10lu "
-                     "(%lu -- %lu)\n", alow, ahigh, b, blow, bhigh);
+              printf("2: alow: %-4zu ahigh: %-4zu. b: %-10zu "
+                     "(%zu -- %zu)\n", alow, ahigh, b, blow, bhigh);
               */
               for(a=alow;a<ahigh;++a)
                 {
@@ -1736,7 +1736,7 @@ corrconvindexs(struct gal_mesh_params *mp, size_t 
**indexs,
           ahigh=s0;
 
           /* For a check:
-          printf("3: alow: %-4lu ahigh: %-4lu. b: %-10lu (%lu -- %lu)\n",
+          printf("3: alow: %-4zu ahigh: %-4zu. b: %-10zu (%zu -- %zu)\n",
                  alow, ahigh, b, blow, bhigh);
           */
           for(a=alow;a<ahigh;++a)
@@ -1795,7 +1795,7 @@ gal_mesh_change_to_full_convolution(struct 
gal_mesh_params *mp, float *conv)
   scp=malloc(mp->numthreads*sizeof *scp);
   if(scp==NULL)
     error(EXIT_FAILURE, errno,
-          "%lu bytes for scp in gal_mesh_change_to_full_convolution "
+          "%zu bytes for scp in gal_mesh_change_to_full_convolution "
           "(mesh.c)", mp->numthreads*sizeof *scp);
 
 
@@ -1832,7 +1832,7 @@ gal_mesh_change_to_full_convolution(struct 
gal_mesh_params *mp, float *conv)
             err=pthread_create(&t, &attr, gal_spatialconvolve_thread,
                                &scp[i]);
             if(err)
-              error(EXIT_FAILURE, 0, "can't create thread %lu", i);
+              error(EXIT_FAILURE, 0, "can't create thread %zu", i);
           }
 
       /* Wait for all threads to finish and free the spaces. */
diff --git a/lib/mode.c b/lib/mode.c
index 86aeeaa..7cc5ec1 100644
--- a/lib/mode.c
+++ b/lib/mode.c
@@ -85,7 +85,7 @@ makemirrored(float *in, size_t mi, float **outmirror, size_t 
*outsize)
   errno=0;
   mirror=malloc(size*sizeof *mirror);
   if(mirror==NULL)
-    error(EXIT_FAILURE, errno, "%lu bytes for mirror array in "
+    error(EXIT_FAILURE, errno, "%zu bytes for mirror array in "
           "makemirrored (mode.c)", size*sizeof *mirror);
 
   for(i=0;i<=mi;++i)
@@ -165,7 +165,7 @@ mirrormaxdiff(float *a, size_t size, size_t m,
 
   /*
   printf("###############\n###############\n");
-  printf("### Mirror pixel: %lu\n", m);
+  printf("### Mirror pixel: %zu\n", m);
   printf("###############\n###############\n");
   */
   /* Go over the mirrored points. */
@@ -189,7 +189,7 @@ mirrormaxdiff(float *a, size_t size, size_t m,
               }
           }
       /*
-      printf("i:%-5lu j:%-5lu diff:%-5d maxdiff: %lu\n",
+      printf("i:%-5zu j:%-5zu diff:%-5d maxdiff: %zu\n",
              i, j, (int)j-(int)i, maxdiff);
       */
       /* The index of the actual CDF corresponding the the mirrored
@@ -269,7 +269,7 @@ modegoldenselection(struct gal_statistics_mode_params *mp)
   system(command);
   -------------------------------------------------------------------*/
   /*
-  printf("%-5lu\t%-5lu(%d)\t%-5lu ----> dq: %-5lu di: %d\n",
+  printf("%-5zu\t%-5zu(%d)\t%-5zu ----> dq: %-5zu di: %d\n",
          mp->lowi, mp->midi, (int)mp->midd, mp->highi,
          di, (int)dd);
   */
diff --git a/lib/polygon.c b/lib/polygon.c
index 11b134d..e67d17d 100644
--- a/lib/polygon.c
+++ b/lib/polygon.c
@@ -135,7 +135,7 @@ gal_polygon_ordered_corners(double *in, size_t n, size_t 
*ordinds)
   /* For a check:
   printf("\n\nBefore sorting:\n");
   for(i=0;i<n;++i)
-    printf("%lu: %.3f, %.3f\n", i, in[i*2], in[i*2+1]);
+    printf("%zu: %.3f, %.3f\n", i, in[i*2], in[i*2+1]);
   printf("\n");
   */
 
@@ -160,7 +160,7 @@ gal_polygon_ordered_corners(double *in, size_t n, size_t 
*ordinds)
                      in[ ordinds[i+1]*2 ]   - in[ ordinds[0]*2   ] );
   /* For a check:
   for(i=0;i<n-1;++i)
-    printf("%lu: %.3f degrees\n", ordinds[i+1], angles[i]*180/M_PI);
+    printf("%zu: %.3f degrees\n", ordinds[i+1], angles[i]*180/M_PI);
   printf("\n");
   */
 
@@ -174,7 +174,7 @@ gal_polygon_ordered_corners(double *in, size_t n, size_t 
*ordinds)
   /* For a check:
   printf("\nAfter sorting:\n");
   for(i=0;i<n;++i)
-    printf("%lu: %.3f, %.3f\n", ordinds[i], in[ordinds[i]*2],
+    printf("%zu: %.3f, %.3f\n", ordinds[i], in[ordinds[i]*2],
            in[ordinds[i]*2+1]);
   printf("\n");
   */
@@ -385,8 +385,8 @@ gal_polygon_clip(double *s, size_t n, double *c, size_t m,
   /*
   if(n>GAL_POLYGON_MAX_CORNERS || m>GAL_POLYGON_MAX_CORNERS)
     error(EXIT_FAILURE, 0, "the two polygons given to the function "
-          "gal_polygon_clip in polygon.c have %lu and %lu vertices. They 
cannot"
-          " have any values larger than %lu", n, m, GAL_POLYGON_MAX_CORNERS);
+          "gal_polygon_clip in polygon.c have %zu and %zu vertices. They 
cannot"
+          " have any values larger than %zu", n, m, GAL_POLYGON_MAX_CORNERS);
   */
 
   /* 2*outnum because for each vertice, there are two elements. */
@@ -395,7 +395,7 @@ gal_polygon_clip(double *s, size_t n, double *c, size_t m,
   while(i<m)                    /* clipEdge: c[ii*2] -- c[i*2]. */
     {
       /*
-      printf("#################\nclipEdge %lu\n", i);
+      printf("#################\nclipEdge %zu\n", i);
       printf("(%.3f, %.3f) -- (%.3f, %.3f)\n----------------\n",
              c[ii*2], c[ii*2+1], c[i*2], c[i*2+1]);
       */
@@ -422,7 +422,7 @@ gal_polygon_clip(double *s, size_t n, double *c, size_t m,
           /*
           {
             size_t k;
-            printf("(%.3f, %.3f) -- (%.3f, %.3f): %lu\n",
+            printf("(%.3f, %.3f) -- (%.3f, %.3f): %zu\n",
                    S[0], S[1], E[0], E[1], outnum);
             for(k=0;k<outnum;++k)
               printf("\t (%.3f, %.3f)\n", o[k*2], o[k*2+1]);
@@ -433,7 +433,7 @@ gal_polygon_clip(double *s, size_t n, double *c, size_t m,
         }
       ii=i++;
       /*
-      printf("outnum: %lu\n\n\n\n", outnum);
+      printf("outnum: %zu\n\n\n\n", outnum);
       */
     }
   *numcrn=outnum;
diff --git a/lib/spatialconvolve.c b/lib/spatialconvolve.c
index d108f34..10426a6 100644
--- a/lib/spatialconvolve.c
+++ b/lib/spatialconvolve.c
@@ -178,7 +178,7 @@ gal_spatialconvolve_convolve(float *input, size_t is0, 
size_t is1,
   errno=0;
   scp=malloc(numthreads*sizeof *scp);
   if(scp==NULL)
-    error(EXIT_FAILURE, errno, "%lu bytes in gal_spatialconvolve_convolve "
+    error(EXIT_FAILURE, errno, "%zu bytes in gal_spatialconvolve_convolve "
           "(spatialconvolve.c) for scp", numthreads*sizeof *scp);
 
 
@@ -186,7 +186,7 @@ gal_spatialconvolve_convolve(float *input, size_t is0, 
size_t is1,
   errno=0;
   *out=malloc(is0*is1*sizeof **out);
   if(*out==NULL)
-    error(EXIT_FAILURE, errno, "%lu bytes for convolution output",
+    error(EXIT_FAILURE, errno, "%zu bytes for convolution output",
           is0*is1*sizeof **out);
 
 
@@ -222,7 +222,7 @@ gal_spatialconvolve_convolve(float *input, size_t is0, 
size_t is1,
             err=pthread_create(&t, &attr, gal_spatialconvolve_thread,
                                &scp[i]);
             if(err)
-              error(EXIT_FAILURE, 0, "can't create thread %lu", i);
+              error(EXIT_FAILURE, 0, "can't create thread %zu", i);
           }
 
       /* Wait for all threads to finish and free the spaces. */
diff --git a/lib/statistics.c b/lib/statistics.c
index 8737bd7..598346c 100644
--- a/lib/statistics.c
+++ b/lib/statistics.c
@@ -830,7 +830,7 @@ gal_statistics_set_bins(float *sorted, size_t size, size_t 
numbins,
   errno=0;
   bins=*obins=calloc((numbins+1)*2, sizeof *bins);
   if(bins==NULL)
-    error(EXIT_FAILURE, errno, "%lu bytes for bins in gal_statistics_set_bins "
+    error(EXIT_FAILURE, errno, "%zu bytes for bins in gal_statistics_set_bins "
           "(statistics.c)", (numbins+1)*2*sizeof *bins);
 
   /* If the range is not defined, find it and set the bin width. */
@@ -869,7 +869,7 @@ gal_statistics_set_bins(float *sorted, size_t size, size_t 
numbins,
 
   /* For a check
   for(i=0;i<numbins;++i)
-    printf("%lu: %.4f\n", i+1, bins[i*2]);
+    printf("%zu: %.4f\n", i+1, bins[i*2]);
   */
 }
 
@@ -893,7 +893,7 @@ gal_statistics_histogram(float *sorted, size_t size, float 
*bins,
   for(i=0;i<size;++i)
     {
       /* For a check:
-      printf("%f:\n  histrow: %lu, numbins: %lu\n",
+      printf("%f:\n  histrow: %zu, numbins: %zu\n",
              sorted[i], histrow, numbins);
       */
       /* Data has not reached bins yet: */
@@ -913,7 +913,7 @@ gal_statistics_histogram(float *sorted, size_t size, float 
*bins,
           if(++histrow==numbins-1) break;
 
       /* For a check:
-      printf("  histrow: %lu\n", histrow);
+      printf("  histrow: %zu\n", histrow);
       */
       ++bins[histrow*2+1];
     }
@@ -935,7 +935,7 @@ gal_statistics_histogram(float *sorted, size_t size, float 
*bins,
 
   /* In case you want to see the histogram:
   for(i=0;i<numbins;++i)
-    printf("%lu: %.4f %.4F\n", i+1, bins[i*2], bins[i*2+1]);
+    printf("%zu: %.4f %.4F\n", i+1, bins[i*2], bins[i*2+1]);
   */
 }
 
@@ -1013,7 +1013,7 @@ gal_statistics_cumulative_fp(float *sorted, size_t size, 
float *bins,
 
   /* In case you want to see the CFP:
   for(i=0;i<numbins;++i)
-    printf("%lu: %.4f %.4F\n", i+1, bins[i*2], bins[i*2+1]);
+    printf("%zu: %.4f %.4F\n", i+1, bins[i*2], bins[i*2+1]);
   */
 }
 
@@ -1047,7 +1047,7 @@ gal_statistics_save_hist(float *sorted, size_t size, 
size_t numbins,
   if(fp==NULL)
     error(EXIT_FAILURE, errno, "couldn't open file %s", filename);
   fprintf(fp, "%s\n", comment);
-  fprintf(fp, "# The input %lu points binned in %lu bins\n#\n",
+  fprintf(fp, "# The input %zu points binned in %zu bins\n#\n",
           size, numbins);
   fprintf(fp, "# Column 0: Value in the middle of this bin.\n");
   fprintf(fp, "# Column 1: Number of points in this bin.\n");
@@ -1094,7 +1094,7 @@ gal_statistics_index_from_quantile(size_t size, float 
quant)
   floatindex=(float)size*quant;
 
   /*
-  printf("quant: %f, size: %lu, findex: %f\n", quant, size, floatindex);
+  printf("quant: %f, size: %zu, findex: %f\n", quant, size, floatindex);
   */
   /* Note that in the conversion from float to size_t, the floor
      integer value of the float will be used. */
@@ -1159,7 +1159,7 @@ gal_statistics_sigma_clip_converge(float *array, int 
o1_n0, size_t num_elem,
       gal_statistics_f_ave_std(start, num_elem, &ave, &std, NULL);
 
       if(print)
-        printf("      %lu: %f  %f  %f  %lu\n",
+        printf("      %zu: %f  %f  %f  %zu\n",
                counter+1, med, ave, std, num_elem);
 
       /* It might happen that ave and std are NaN. If so, stop the
@@ -1233,7 +1233,7 @@ gal_statistics_sigma_clip_certain_num(float *array, int 
o1_n0, size_t num_elem,
       gal_statistics_f_ave_std(start, num_elem, &ave, &std, NULL);
 
       if(print)
-        printf("      %lu: %f  %f  %f  %lu\n",
+        printf("      %zu: %f  %f  %f  %zu\n",
                counter+1, med, ave, std, num_elem);
 
       /* It might happen that ave and std are nan. If so, stop the
@@ -1302,7 +1302,7 @@ gal_statistics_remove_outliers_flat_cdf(float *sorted, 
size_t *outsize)
      you want to think about slopes. */
   errno=0; slopes=malloc(size*sizeof *slopes);
   if(slopes==NULL)
-    error(EXIT_FAILURE, errno, "%lu bytes for slopes in "
+    error(EXIT_FAILURE, errno, "%zu bytes for slopes in "
           "gal_statistics_remove_outliers_flat_cdf (statistics.c)",
           size*sizeof *slopes);
 
@@ -1338,8 +1338,8 @@ gal_statistics_remove_outliers_flat_cdf(float *sorted, 
size_t *outsize)
 
   /*
   for(i=0;i<size;++i)
-    printf("%lu\t%.3f\t%.3f\n", i, arr[i], slopes[i]);
-  printf("\n\nPlace to cut off for outliers is: %lu\n\n", *outsize);
+    printf("%zu\t%.3f\t%.3f\n", i, arr[i], slopes[i]);
+  printf("\n\nPlace to cut off for outliers is: %zu\n\n", *outsize);
   */
 
   free(slopes);
@@ -1406,7 +1406,7 @@ gal_statistics_mode_mirror_plots(float *sorted, size_t 
size, size_t mirrorindex,
   errno=0;
   out=malloc(numbins*3*sizeof *out);
   if(out==NULL)
-    error(EXIT_FAILURE, errno, "%lu bytes for out in "
+    error(EXIT_FAILURE, errno, "%zu bytes for out in "
           "gal_mode_make_mirror_plots (mode.c)", numbins*3*sizeof *out);
 
 
diff --git a/lib/threads.c b/lib/threads.c
index 27575fa..b812865 100644
--- a/lib/threads.c
+++ b/lib/threads.c
@@ -200,9 +200,9 @@ gal_threads_dist_in_threads(size_t numactions, size_t 
numthreads,
     {
       size_t j;
       printf("\n\n############################\n");
-      printf("THREAD %lu: \n", i);
+      printf("THREAD %zu: \n", i);
       for(j=0;thrds[i*thrdcols+j]!=GAL_THREADS_NON_THRD_INDEX;j++)
-        printf("%lu, ", thrds[i*thrdcols+j]);
+        printf("%zu, ", thrds[i*thrdcols+j]);
       printf("\b\b.\n");
     }
   exit(0);
diff --git a/lib/txtarray.c b/lib/txtarray.c
index 6ea2123..0b5a54c 100644
--- a/lib/txtarray.c
+++ b/lib/txtarray.c
@@ -65,7 +65,7 @@ txttablesize(char *filename, size_t *outs0, size_t *outs1)
   errno=0;
   line=malloc(len*sizeof *line);
   if(line==NULL)
-    error(EXIT_FAILURE, errno, "ui.c: %lu bytes in readdefaults",
+    error(EXIT_FAILURE, errno, "ui.c: %zu bytes in readdefaults",
           len * sizeof *line);
 
   /* Open the file: */
@@ -119,7 +119,7 @@ savetolog(FILE **log, char *filename, size_t lineno, size_t 
s0,
           size_t s1, char *token)
 {
   if(*log)                        /* The file is already open. */
-    fprintf(*log, "%-10lu%-10lu%-10lu%s\n", lineno, s0, s1, token);
+    fprintf(*log, "%-10zu%-10zu%-10zu%s\n", lineno, s0, s1, token);
   else                            /* Not yet created.          */
     {
       errno=0;
@@ -136,7 +136,7 @@ savetolog(FILE **log, char *filename, size_t lineno, size_t 
s0,
               "# 3: The string that could not be converted to a number.\n"
               "# Note that counting starts from zero.\n",
               filename);
-      fprintf(*log, "%-10lu%-10lu%-10lu%s\n", lineno-1, s0, s1, token);
+      fprintf(*log, "%-10zu%-10zu%-10zu%s\n", lineno-1, s0, s1, token);
     }
 }
 
@@ -188,7 +188,7 @@ filltable(char *filename, double *array, size_t s0, size_t 
s1)
   errno=0;
   line=malloc(len*sizeof *line);
   if(line==NULL)
-    error(EXIT_FAILURE, errno, "ui.c: %lu bytes in readdefaults",
+    error(EXIT_FAILURE, errno, "ui.c: %zu bytes in readdefaults",
           len * sizeof *line);
 
   ts0=0;
@@ -263,7 +263,7 @@ gal_txtarray_txt_to_array(char *filename, double **array,
   txttablesize(filename, s0, s1);
   if( (*array=malloc(*s0 * *s1 * sizeof **array)) == NULL)
     error(EXIT_FAILURE, errno, "gal_txtarray_txt_to_array: space for "
-          "array with %lu elements", *s0 * *s1);
+          "array with %zu elements", *s0 * *s1);
 
   /* Fill in the table with the contents of the text file: */
   filltable(filename, *array, *s0, *s1);
@@ -382,12 +382,12 @@ gal_txtarray_array_to_txt(double *array, size_t s0, 
size_t s1,
   for(i=0;int_cols[i]>0;++i)
     if(int_cols[i]>=s1)
       error(EXIT_FAILURE, 0, "gal_txtarray_array_to_txt: In int_cols[], "
-            "%d is larger than the number of columns: %lu", int_cols[i],
+            "%d is larger than the number of columns: %zu", int_cols[i],
             s1);
   for(i=0;accu_cols[i]>0;++i)
     if(accu_cols[i]>=s1)
       error(EXIT_FAILURE, 0, "gal_txtarray_array_to_txt: In accu_cols[], "
-            "%d is larger than the number of columns: %lu", accu_cols[i],
+            "%d is larger than the number of columns: %zu", accu_cols[i],
             s1);
   for(i=0;i<3;++i)
     if(space[i]<=0)
@@ -403,7 +403,7 @@ gal_txtarray_array_to_txt(double *array, size_t s0, size_t 
s1,
   fmt=malloc(s1 * sizeof(char *));
   if(fmt==NULL)
     error(EXIT_FAILURE, errno, "txtarray, formatting of each "
-          "column with %lu elements", s1);
+          "column with %zu elements", s1);
 
   /* Prepare the formatting for each column */
   gal_txtarray_printf_format(s1, fmt, int_cols, accu_cols,
diff --git a/tests/lib/arraymanip.c b/tests/lib/arraymanip.c
index 1b2c945..8f0d557 100644
--- a/tests/lib/arraymanip.c
+++ b/tests/lib/arraymanip.c
@@ -35,7 +35,7 @@ main(void)
   array=malloc(size * sizeof *array);
   if(array==NULL)
     {
-      fprintf(stderr, "%lu bytes for d.\n", size);
+      fprintf(stderr, "%zu bytes for d.\n", size);
       exit(EXIT_FAILURE);
     }
 
diff --git a/tests/lib/multithread.c b/tests/lib/multithread.c
index 9c836d6..98c1816 100644
--- a/tests/lib/multithread.c
+++ b/tests/lib/multithread.c
@@ -60,7 +60,7 @@ worker(void *inparam)
       /* The indexes of the actions will make it possible to point to
          whatever data structure or input you want. So in this test, we
          will just print the thread ID and action id. */
-      printf("thread %lu: %lu\n", prm->id, prm->indexs[i]);
+      printf("thread %zu: %zu\n", prm->id, prm->indexs[i]);
     }
 
   /* Wait until all other threads finish. When there was only one thread,
@@ -96,7 +96,7 @@ main(void)
   prm=malloc(numthreads*sizeof *prm);
   if(prm==NULL)
     {
-      fprintf(stderr, "%lu bytes could not be allocated for prm.",
+      fprintf(stderr, "%zu bytes could not be allocated for prm.",
               numthreads*sizeof *prm);
       exit(EXIT_FAILURE);
     }
@@ -135,7 +135,7 @@ main(void)
             err=pthread_create(&t, &attr, worker, &prm[i]);
             if(err)
               {
-                fprintf(stderr, "can't create thread %lu", i);
+                fprintf(stderr, "can't create thread %zu", i);
                 exit(EXIT_FAILURE);
               }
           }



reply via email to

[Prev in Thread] Current Thread [Next in Thread]