diff --git a/src/cdi_int.h b/src/cdi_int.h
index c9ba92cc406cd2b29f37cbc3be8ea20519b87e21..fd7316ad1c13751274dd474fba173995b5856277 100644
--- a/src/cdi_int.h
+++ b/src/cdi_int.h
@@ -1,6 +1,14 @@
 #ifndef CDI_INT_H
 #define CDI_INT_H
 
+// strdup() from string.h
+#ifdef __STDC_ALLOC_LIB__
+#define __STDC_WANT_LIB_EXT2__ 1
+#else
+#undef _POSIX_C_SOURCE
+#define _POSIX_C_SOURCE 200809L
+#endif
+
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
@@ -27,22 +35,6 @@
 #define UNUSED(x) (void) x
 #endif
 
-#ifndef strdupx
-#ifndef strdup
-char *strdup(const char *s);
-#endif
-#define strdupx strdup
-/*
-#define strdupx(s)			          \
-({					      	  \
-   const char *__old = (s);			  \
-   size_t __len = strlen(__old) + 1;		  \
-   char *__new = (char *) Malloc(__len);	  \
-   (char *) memcpy(__new, __old, __len);	  \
-})
-*/
-#endif
-
 char *str_to_lower(char *str);
 bool strStartsWith(const char *vstr, const char *cstr);
 
diff --git a/src/file.c b/src/file.c
index 58c2c10a558799cee48c4caef92f21b76a8fbe04..95b43b975f5705c74d18fb21d64a844c2b941a08 100644
--- a/src/file.c
+++ b/src/file.c
@@ -1,3 +1,11 @@
+// strdup() from string.h
+#ifdef __STDC_ALLOC_LIB__
+#define __STDC_WANT_LIB_EXT2__ 1
+#else
+#undef _POSIX_C_SOURCE
+#define _POSIX_C_SOURCE 200809L
+#endif
+
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
@@ -33,10 +41,6 @@
 #define O_BINARY 0
 #endif
 
-#ifndef strdup
-char *strdup(const char *s);
-#endif
-
 #ifdef HAVE_MMAP
 #include <sys/mman.h>  // mmap() is defined in this header
 #endif
diff --git a/src/gribapi_utilities.c b/src/gribapi_utilities.c
index ca9f8e090a75eaebbf13dba0b18ab58622d0fd1c..03734fb55d2f8508da73403b82639360ec181b96 100644
--- a/src/gribapi_utilities.c
+++ b/src/gribapi_utilities.c
@@ -836,7 +836,7 @@ gribapiGetGridUnstructured(grib_handle *gh, grid_t *grid, size_t numberOfPoints)
         if ( grib_get_string(gh, "gridDescriptionFile", reference_link, &len) == 0 )
         {
         if ( strncmp(reference_link, "file://", 7) == 0 )
-        grid->reference = strdupx(reference_link);
+        grid->reference = strdup(reference_link);
         }
       */
       size_t len = (size_t) CDI_UUID_SIZE;
diff --git a/src/institution.c b/src/institution.c
index 89c4f278f6d7f75120bb942949c3bfb8225e37c5..b93bd7580d90f57bcad1b959748d97384b47637f 100644
--- a/src/institution.c
+++ b/src/institution.c
@@ -158,8 +158,8 @@ instituteNewEntry(cdiResH resH, int center, int subcenter, const char *name, con
     }
   instituteptr->center = center;
   instituteptr->subcenter = subcenter;
-  if (name && *name) instituteptr->name = strdupx(name);
-  if (longname && *longname) instituteptr->longname = strdupx(longname);
+  if (name && *name) instituteptr->name = strdup(name);
+  if (longname && *longname) instituteptr->longname = strdup(longname);
   return instituteptr;
 }
 
diff --git a/src/model.c b/src/model.c
index 9cf80506230c7a017de5b0552f19eec101355093..ef3ad02235d378a760bbda88f4262249f26e4ae0 100644
--- a/src/model.c
+++ b/src/model.c
@@ -54,7 +54,7 @@ modelNewEntry(cdiResH resH, int instID, int modelgribID, const char *name)
     }
   modelptr->instID = instID;
   modelptr->modelgribID = modelgribID;
-  if (name && *name) modelptr->name = strdupx(name);
+  if (name && *name) modelptr->name = strdup(name);
 
   return (modelptr);
 }
diff --git a/src/stream.c b/src/stream.c
index e302be77389f23fd8ce12e4132dfbb738426ae94..48cad842a4ff7c02452b920f61e80545ec66e4ab 100644
--- a/src/stream.c
+++ b/src/stream.c
@@ -680,7 +680,7 @@ streamOpenID(const char *filename, char filemode, int filetype, int resH)
       if (streamID < 0) return CDI_ELIMIT;
 
       streamptr->filemode = filemode;
-      streamptr->filename = strdupx(filename);
+      streamptr->filename = strdup(filename);
       streamptr->fileID = fileID;
     }
 
@@ -717,7 +717,7 @@ streamOpenA(const char *filename, const char *filemode, int filetype)
   int streamID = streamptr->self;
 
   streamptr->filemode = tolower(*filemode);
-  streamptr->filename = strdupx(filename);
+  streamptr->filename = strdup(filename);
   streamptr->fileID = fileID;
 
   streamptr->vlistID = vlistCreate();
diff --git a/src/table.c b/src/table.c
index 48a776b4a0f1e76a89c8bbc4e1a54671fdd43607..ccb7714785c0dc9584519e7a58f8cbbe0b86071f 100644
--- a/src/table.c
+++ b/src/table.c
@@ -51,17 +51,17 @@ tableDefEntry(int tableID, int id, int ltype, const char *name, const char *long
 
   if (name && name[0])
     {
-      parTable[tableID].pars[item].name = strdupx(name);
+      parTable[tableID].pars[item].name = strdup(name);
       parTable[tableID].pars[item].dupflags |= TABLE_DUP_NAME;
     }
   if (longname && longname[0])
     {
-      parTable[tableID].pars[item].longname = strdupx(longname);
+      parTable[tableID].pars[item].longname = strdup(longname);
       parTable[tableID].pars[item].dupflags |= TABLE_DUP_LONGNAME;
     }
   if (units && units[0])
     {
-      parTable[tableID].pars[item].units = strdupx(units);
+      parTable[tableID].pars[item].units = strdup(units);
       parTable[tableID].pars[item].dupflags |= TABLE_DUP_UNITS;
     }
 }
@@ -97,7 +97,7 @@ static void
 tableGetPath(void)
 {
   char *path = getenv("TABLEPATH");
-  if (path) tablePath = strdupx(path);
+  if (path) tablePath = strdup(path);
   // printf("tablePath = %s\n", tablePath);
 }
 
@@ -500,7 +500,7 @@ tableDef(int modelID, int tablenum, const char *tablename)
 
       parTable[tableID].modelID = modelID;
       parTable[tableID].number = tablenum;
-      if (tablename) parTable[tableID].name = strdupx(tablename);
+      if (tablename) parTable[tableID].name = strdup(tablename);
 
       parTable[tableID].pars = (param_type *) Malloc(MAX_PARS * sizeof(param_type));
     }
diff --git a/src/varscan.c b/src/varscan.c
index b00cda6f78178fb080a7adba32ed8faf6967c0cc..7f7429495c934717ea445c82d39e48d6336e54ba 100644
--- a/src/varscan.c
+++ b/src/varscan.c
@@ -693,7 +693,7 @@ cdi_generate_vars(stream_t *streamptr)
           vlistptr->vars[varID].opt_grib_kvpair[idx] = vartable[varid].opt_grib_kvpair[i];
           vlistptr->vars[varID].opt_grib_kvpair[idx].keyword = NULL;
           if (vartable[varid].opt_grib_kvpair[i].keyword)
-            vlistptr->vars[varID].opt_grib_kvpair[idx].keyword = strdupx(vartable[varid].opt_grib_kvpair[i].keyword);
+            vlistptr->vars[varID].opt_grib_kvpair[idx].keyword = strdup(vartable[varid].opt_grib_kvpair[i].keyword);
           vlistptr->vars[varID].opt_grib_kvpair[i].update = true;
         }
       // note: if the key is not defined, we do not throw an error!
@@ -1091,7 +1091,7 @@ varDefOptGribInt(int varID, int tile_index, long lval, const char *keyword)
     }
   vartable[varID].opt_grib_kvpair[idx].data_type = t_int;
   vartable[varID].opt_grib_kvpair[idx].int_val = (int) lval;
-  vartable[varID].opt_grib_kvpair[idx].keyword = strdupx(keyword);
+  vartable[varID].opt_grib_kvpair[idx].keyword = strdup(keyword);
   vartable[varID].opt_grib_kvpair[idx].subtype_index = tile_index;
 }
 #endif
@@ -1121,7 +1121,7 @@ varDefOptGribDbl(int varID, int tile_index, double dval, const char *keyword)
     }
   vartable[varID].opt_grib_kvpair[idx].data_type = t_double;
   vartable[varID].opt_grib_kvpair[idx].dbl_val = dval;
-  vartable[varID].opt_grib_kvpair[idx].keyword = strdupx(keyword);
+  vartable[varID].opt_grib_kvpair[idx].keyword = strdup(keyword);
   vartable[varID].opt_grib_kvpair[idx].subtype_index = tile_index;
 }
 #endif
diff --git a/src/vlist.c b/src/vlist.c
index 743d5bd1833594c7151fc78b67a942826f7d25e9..77cd51b6862bda6fb0bafdcced249c908bb82ae8 100644
--- a/src/vlist.c
+++ b/src/vlist.c
@@ -299,7 +299,7 @@ var_copy_entries(var_t *var2, var_t *var1)
       if (var1->opt_grib_kvpair[i].keyword != NULL)
         {
           var2->opt_grib_kvpair[i] = var1->opt_grib_kvpair[i];
-          var2->opt_grib_kvpair[i].keyword = strdupx(var1->opt_grib_kvpair[i].keyword);
+          var2->opt_grib_kvpair[i].keyword = strdup(var1->opt_grib_kvpair[i].keyword);
           var2->opt_grib_kvpair[i].update = true;
           if (CDI_Debug) Message("done.");
         }
diff --git a/src/vlist_var_key.c b/src/vlist_var_key.c
index 651e319811c440a7bc602ebc78856d10c7d372fd..10fe1602daf3bbf206ebc470c030f89d0df87294 100644
--- a/src/vlist_var_key.c
+++ b/src/vlist_var_key.c
@@ -40,7 +40,7 @@ vlistDefVarIntKey(int vlistID, int varID, const char *name, int value)
       vlistptr->vars[varID].opt_grib_kvpair[idx].int_val = value;
       vlistptr->vars[varID].opt_grib_kvpair[idx].update = true;
       if (name)
-        vlistptr->vars[varID].opt_grib_kvpair[idx].keyword = strdupx(name);
+        vlistptr->vars[varID].opt_grib_kvpair[idx].keyword = strdup(name);
       else
         Error("Internal error, name undefined!");
     }
@@ -103,7 +103,7 @@ vlistDefVarDblKey(int vlistID, int varID, const char *name, double value)
       vlistptr->vars[varID].opt_grib_kvpair[idx].dbl_val = value;
       vlistptr->vars[varID].opt_grib_kvpair[idx].update = true;
       if (name)
-        vlistptr->vars[varID].opt_grib_kvpair[idx].keyword = strdupx(name);
+        vlistptr->vars[varID].opt_grib_kvpair[idx].keyword = strdup(name);
       else
         Error("Internal error, name undefined!");
     }
@@ -151,7 +151,7 @@ cdiDefAdditionalKey(const char *name)
   cdiNAdditionalGRIBKeys++;
   if (idx >= MAX_OPT_GRIB_ENTRIES) Error("Too many additional keywords!");
   if (name)
-    cdiAdditionalGRIBKeys[idx] = strdupx(name);
+    cdiAdditionalGRIBKeys[idx] = strdup(name);
   else
     Error("Internal error!");
 #else