diff --git a/src/stream.c b/src/stream.c
index f3a11f7c81df0494610670f4a9aa27cea5621718..7c674bbf43a9bbc6696eb2275359c6ab9f29d8d1 100644
--- a/src/stream.c
+++ b/src/stream.c
@@ -721,7 +721,7 @@ streamOpenNCMem(int ncidp, char mode)
   stream_t *streamptr = stream_new_entry(CDI_UNDEFID);
   int streamID = CDI_ESYSTEM;
 
-#ifdef HAVE_NETCDF4
+#ifdef HAVE_NETCDF5
   streamID = streamptr->self;
   if (streamID < 0) return CDI_ELIMIT;
 
@@ -733,7 +733,7 @@ streamOpenNCMem(int ncidp, char mode)
 
   streamptr->filename = strdup(filename);
   streamptr->filemode = mode;
-  streamptr->filetype = CDI_FILETYPE_NC4;
+  streamptr->filetype = CDI_FILETYPE_NC5;
   streamptr->fileID = ncidp;
 
   if (mode == 'r')