Index: .gitignore
===================================================================
--- .gitignore	(revision 660cdd6a391638064e59cc8406d1c5a6ec0c2bcc)
+++ .gitignore	(revision df4dc86e6a7ca1d5dd8961a1f3a5f0f54d3f8e37)
@@ -4,4 +4,5 @@
 *.cl
 *.so
+*.obj
 /doc/_build/
 /doc/api/
Index: compare.sh
===================================================================
--- compare.sh	(revision 8a3e0af2c1322a8ce6217730abca4629145a03ea)
+++ compare.sh	(revision 8a3e0af2c1322a8ce6217730abca4629145a03ea)
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+#SASVIEW=$(ls -d ../sasview/build/lib.*)
+SASVIEW=( ../sasview/build/lib.* )
+#PYOPENCL_CTX=${CTX:-1}
+PYTHONPATH=../bumps:../periodictable:$SASVIEW
+export PYOPENCL_CTX PYTHONPATH
+
+echo PYTHONPATH=$PYTHONPATH
+set -x
+
+./compare.py $*
Index: sasmodels/dll.py
===================================================================
--- sasmodels/dll.py	(revision 216a9e18553fc7fc834b3d97336740ee36bf81be)
+++ sasmodels/dll.py	(revision df4dc86e6a7ca1d5dd8961a1f3a5f0f54d3f8e37)
@@ -4,4 +4,5 @@
 import sys
 import os
+import tempfile
 import ctypes as ct
 from ctypes import c_void_p, c_int, c_double
@@ -15,10 +16,17 @@
 if sys.platform == 'darwin':
     #COMPILE = "gcc-mp-4.7 -shared -fPIC -std=c99 -fopenmp -O2 -Wall %s -o %s -lm -lgomp"
-    COMPILE = "gcc -shared -fPIC -std=c99 -O2 -Wall %s -o %s -lm"
+    COMPILE = "gcc -shared -fPIC -std=c99 -O2 -Wall %(source)s -o %(output)s -lm"
 elif os.name == 'nt':
-    COMPILE = "gcc -shared -fPIC -std=c99 -fopenmp -O2 -Wall %s -o %s -lm"
+    # make sure vcvarsall.bat is called first in order to set compiler, headers, lib paths, etc.
+    ##COMPILER = r'"C:\Program Files (x86)\Common Files\Microsoft\Visual C++ for Python\9.0\VC\Bin\cl.exe"'
+    # Can't find VCOMP90.DLL (don't know why), so remove openmp support from windows compiler build
+    #COMPILE = "cl /nologo /Ox /MD /W3 /GS- /DNDEBUG /Tp%(source)s /link /DLL /INCREMENTAL:NO /MANIFEST /OUT:%(output)s"
+    COMPILE = "cl /nologo /Ox /MD /W3 /GS- /DNDEBUG /Tp%(source)s /openmp /link /DLL /INCREMENTAL:NO /MANIFEST /OUT:%(output)s"
+    #/MANIFESTFILE:build\temp.win32-2.7\Release\src\sans\models\c_extension\libigor\c_models.pyd.manifest
+    #COMPILE = "gcc -shared -fPIC -std=c99 -fopenmp -O2 -Wall %(source)s -o %(output)s -lm"
 else:
-    COMPILE = "cc -shared -fPIC -std=c99 -fopenmp -O2 -Wall %s -o %s -lm"
-DLL_PATH = "/tmp"
+    COMPILE = "cc -shared -fPIC -std=c99 -fopenmp -O2 -Wall %(source)s -o %(output)s -lm"
+
+DLL_PATH = tempfile.gettempdir()
 
 
@@ -53,5 +61,7 @@
         fid, filename = tempfile.mkstemp(suffix=".c",prefix="sas_"+info['name'])
         os.fdopen(fid,"w").write(source)
-        status = os.system(COMPILE%(filename, dllpath))
+        command = COMPILE%{"source":filename, "output":dllpath}
+        print "Compile command:",command
+        status = os.system(command)
         if status != 0:
             print "compile failed.  File is in %r"%filename
@@ -91,4 +101,5 @@
         Npd2d = len(self.info['partype']['pd-2d'])
 
+        #print "dll",self.dllpath
         self.dll = ct.CDLL(self.dllpath)
 
Index: sasmodels/gen.py
===================================================================
--- sasmodels/gen.py	(revision 3699587640935d2c594f53ec1f8a73310494a590)
+++ sasmodels/gen.py	(revision df4dc86e6a7ca1d5dd8961a1f3a5f0f54d3f8e37)
@@ -226,10 +226,26 @@
 // Note: if using a C++ compiler, then define kernel as extern "C"
 #ifndef USE_OPENCL
-#  include <math.h>
+#  ifdef __cplusplus
+     #include <cmath>
+     #if defined(_MSC_VER)
+     #define kernel extern "C" __declspec( dllexport )
+     #else
+     #define kernel extern "C"
+     #endif
+     using namespace std;
+     inline void SINCOS(double angle, double &svar, double &cvar)
+       { svar=sin(angle); cvar=cos(angle); }
+#  else
+     #include <math.h>
+     #if defined(_MSC_VER)
+     #define kernel __declspec( dllexport )
+     #else
+     #define kernel
+     #endif
+     #define SINCOS(angle,svar,cvar) do {svar=sin(angle);cvar=cos(angle);} while (0)
+#  endif
 #  define global
 #  define local
 #  define constant const
-#  define kernel
-#  define SINCOS(angle,svar,cvar) do {svar=sin(angle);cvar=cos(angle);} while (0)
 #  define powr(a,b) pow(a,b)
 #else
