diff --git a/src/wrap_cl.hpp b/src/wrap_cl.hpp
index 1253c49955f637f22d72d601d543001ff42e93e5..e25207c41c6b0d5d92e4fc8a09cea647b5569287 100644
--- a/src/wrap_cl.hpp
+++ b/src/wrap_cl.hpp
@@ -90,6 +90,15 @@
 #endif
 
 
+#if defined(_WIN32)
+// MSVC does not understand variable-length arrays
+#define PYOPENCL_STACK_CONTAINER(TYPE, NAME, COUNT) std::vector<TYPE> NAME(COUNT)
+#define PYOPENCL_STACK_CONTAINER_GET_PTR(NAME) (name.size() ? name.data() : nullptr)
+#else
+// gcc et al complain about stripping attributes in template arguments
+#define PYOPENCL_STACK_CONTAINER(TYPE, NAME, COUNT) TYPE NAME[COUNT]
+#define PYOPENCL_STACK_CONTAINER_GET_PTR(NAME) NAME
+#endif
 
 // }}}
 
@@ -1363,7 +1372,7 @@ namespace pyopencl
                 "may be a crash." << std:: endl;
           }
 
-          std::vector<cl_queue_properties> props(py::len(py_props) + 1);
+          PYOPENCL_STACK_CONTAINER(cl_queue_properties, props, py::len(py_props) + 1);
           {
             size_t i = 0;
             for (auto prop: py_props)
@@ -1374,7 +1383,7 @@ namespace pyopencl
           cl_int status_code;
           PYOPENCL_PRINT_CALL_TRACE("clCreateCommandQueueWithProperties");
           m_queue = clCreateCommandQueueWithProperties(
-              ctx.data(), dev, props.data(), &status_code);
+              ctx.data(), dev, PYOPENCL_STACK_CONTAINER_GET_PTR(props), &status_code);
 
           if (status_code != CL_SUCCESS)
             throw pyopencl::error("CommandQueue", status_code);
@@ -3610,7 +3619,7 @@ namespace pyopencl
             "may be a crash." << std:: endl;
         }
 
-        std::vector<cl_sampler_properties> props(py::len(py_props) + 1);
+        PYOPENCL_STACK_CONTAINER(cl_sampler_properties, props, py::len(py_props) + 1);
         {
           size_t i = 0;
           for (auto prop: py_props)
@@ -3623,7 +3632,7 @@ namespace pyopencl
 
         m_sampler = clCreateSamplerWithProperties(
             ctx.data(),
-            props.data(),
+            PYOPENCL_STACK_CONTAINER_GET_PTR(props),
             &status_code);
 
         if (status_code != CL_SUCCESS)
@@ -4005,7 +4014,7 @@ namespace pyopencl
       sizes.push_back(len);
     }
 
-    std::vector<cl_int> binary_statuses(num_devices);
+    PYOPENCL_STACK_CONTAINER(cl_int, binary_statuses, num_devices);
 
     cl_int status_code;
     PYOPENCL_PRINT_CALL_TRACE("clCreateProgramWithBinary");
@@ -4014,7 +4023,7 @@ namespace pyopencl
         devices.empty( ) ? nullptr : &devices.front(),
         sizes.empty( ) ? nullptr : &sizes.front(),
         binaries.empty( ) ? nullptr : &binaries.front(),
-        binary_statuses.data(),
+        PYOPENCL_STACK_CONTAINER_GET_PTR(binary_statuses),
         &status_code);
     if (status_code != CL_SUCCESS)
       throw pyopencl::error("clCreateProgramWithBinary", status_code);