From 4b055a4ca8495016f769ac7b27f4a939d97c34f8 Mon Sep 17 00:00:00 2001 From: h_vogt Date: Sun, 21 Sep 2008 22:18:06 +0000 Subject: [PATCH] Small changes to allow compilation with MS Visual C++ 2008 --- ChangeLog | 5 +++++ src/frontend/help/readhelp.c | 4 ++++ src/frontend/measure.c | 2 ++ src/frontend/numparam/xpressn.c | 2 ++ src/frontend/rawfile.c | 6 +++--- src/frontend/resource.c | 5 +++++ src/frontend/runcoms.c | 2 +- src/frontend/wdisp/windisp.c | 3 +++ src/include/complex.h | 4 ++++ src/include/defines.h | 2 +- src/include/ngspice.h | 6 +++++- src/include/wstdio.h | 12 ++++++++++++ src/spicelib/devices/bsim3soi/b4soild.c | 4 ++++ src/spicelib/devices/hisim/hsm1eval102.c | 4 +++- src/spicelib/devices/hisim/hsm1eval112.c | 3 +++ src/spicelib/devices/hisim/hsm1eval120.c | 3 +++ 16 files changed, 60 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5a7f9c369..e31f39932 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2008-09-22 Holger Vogt + * complex.h, measure.c, resource.c, windisp.c, xpressn.c, rawfile.c, runcoms.c, readhelp.c, + defines.h, ngspice.h, b4soild.c, hsm1eval102.c, hsm1eval112.c, hsm1eval120.c, wstdio.h + Small changes to allow compilation with MS Visual C++ 2008 + 2008-09-15 Lionel Sainte Cluque * src/Makefile.am: Add $(DESTDIR) in tclspice installation, required by debian package. * src/Makefile.am: Use -no-undefined only for windows build (libspice_la_LDFLAGS) diff --git a/src/frontend/help/readhelp.c b/src/frontend/help/readhelp.c index 8cc4f98ef..38af93a49 100644 --- a/src/frontend/help/readhelp.c +++ b/src/frontend/help/readhelp.c @@ -17,6 +17,10 @@ Modified 1999 Emmanuel Rouat #include "hlpdefs.h" #include "suffix.h" +#if defined (_MSC_VER) +#define strncasecmp _strnicmp +#endif + static char *getsubject(fplace *place); static toplink *getsubtoplink(char **ss); diff --git a/src/frontend/measure.c b/src/frontend/measure.c index 190b79420..1cfeb9f2e 100644 --- a/src/frontend/measure.c +++ b/src/frontend/measure.c @@ -13,6 +13,7 @@ static bool measure_valid[20000]; static bool just_chk_meas; static bool measures_passed; +#if !defined(_MSC_VER) static double max( double a, double b ) { if ( a > b ) return a; @@ -24,6 +25,7 @@ min( double a, double b ) { if ( a < b ) return a; else return b; } +#endif static int get_measure_precision() diff --git a/src/frontend/numparam/xpressn.c b/src/frontend/numparam/xpressn.c index 3a290f330..cb10ac39e 100644 --- a/src/frontend/numparam/xpressn.c +++ b/src/frontend/numparam/xpressn.c @@ -15,6 +15,7 @@ static Str (150, keys); /* all my keywords */ static Str (150, fmath); /* all math functions */ +#ifndef _MSC_VER static double max (double x, double y) { @@ -26,6 +27,7 @@ min (double x, double y) { return (x < y) ? x : y; } +#endif static double ternary_fcn (int conditional, double if_value, double else_value) diff --git a/src/frontend/rawfile.c b/src/frontend/rawfile.c index cdff57930..8aca3b1db 100644 --- a/src/frontend/rawfile.c +++ b/src/frontend/rawfile.c @@ -63,7 +63,7 @@ raw_write(char *name, struct plot *pl, bool app, bool binary) else prec = DEFPREC; -#ifdef __MINGW32__ +#if defined(__MINGW32__) || defined(_MSC_VER) /* - Binary file binary write - hvogt 15.03.2000 ---------------------*/ if (binary) { if (!(fp = fopen(name, app ? "ab" : "wb"))) { @@ -295,7 +295,7 @@ raw_read(char *name) FILE *fp, *lastin, *lastout, *lasterr; -#ifdef __MINGW32__ +#if defined(__MINGW32__) || defined(_MSC_VER) bool binary = TRUE; #endif @@ -304,7 +304,7 @@ raw_read(char *name) return (NULL); } -#ifdef __MINGW32__ +#if defined(__MINGW32__) || defined(_MSC_VER) /* Test, whether file really ASCII, otherwise assume binary hvogt 15.3.2000 */ while (fgets(buf, BSIZE_SP, fp)) { if (ciprefix("values:", buf)) { diff --git a/src/frontend/resource.c b/src/frontend/resource.c index 757b2ef9d..41c0a826b 100644 --- a/src/frontend/resource.c +++ b/src/frontend/resource.c @@ -23,7 +23,12 @@ $Id$ #include "resource.h" #include "variable.h" #include "cktdefs.h" + +#ifdef _MSC_VER +#include "../misc/misc_time.h" /* timediff */ +#else #include "src/misc/misc_time.h" /* timediff */ +#endif #ifdef XSPICE /* gtri - add - 12/12/90 - wbk - include ipc stuff */ diff --git a/src/frontend/runcoms.c b/src/frontend/runcoms.c index 7e8a4acd9..4ac8bd7c9 100644 --- a/src/frontend/runcoms.c +++ b/src/frontend/runcoms.c @@ -221,7 +221,7 @@ dosim(char *what, wordlist *wl) #endif /* PARALLEL_ARCH */ if (!*wl->wl_word) rawfileFp = stdout; -#ifdef __MINGW32__ +#if defined(__MINGW32__) || defined(_MSC_VER) /* ask if binary or ASCII, open file with w or wb hvogt 15.3.2000 */ else if (ascii) { if(!(rawfileFp = fopen(wl->wl_word, "w"))) { diff --git a/src/frontend/wdisp/windisp.c b/src/frontend/wdisp/windisp.c index a8340bbd7..739476e09 100644 --- a/src/frontend/wdisp/windisp.c +++ b/src/frontend/wdisp/windisp.c @@ -60,6 +60,9 @@ extern int NewViewport(GRAPH *pgraph); /* defines */ #define RAD_TO_DEG (180.0 / M_PI) +#ifndef M_LN10 +#define M_LN10 2.30258509299404568402 +#endif /* local variables */ static int IsRegistered = 0; /* 1 if window class is registered */ diff --git a/src/include/complex.h b/src/include/complex.h index 175228ebb..6ea25f832 100644 --- a/src/include/complex.h +++ b/src/include/complex.h @@ -12,6 +12,10 @@ struct _complex1 { /* IBM portability... renamed due to double definition in M double cx_imag; } ; +#ifdef _MSC_VER +typedef struct _complex1 _complex; +#endif + typedef struct _complex1 complex; #define realpart(cval) ((struct _complex1 *) (cval))->cx_real diff --git a/src/include/defines.h b/src/include/defines.h index c8ae15b51..4c3f5347e 100644 --- a/src/include/defines.h +++ b/src/include/defines.h @@ -74,7 +74,7 @@ /* Alternate initialisation file name */ #define ALT_INITSTR "spice.rc" -#ifdef __MINGW32__ +#if defined(__MINGW32__) || defined(_MSC_VER) #define DIR_PATHSEP "\\" #define DIR_TERM '\\' #define DIR_CWD "." diff --git a/src/include/ngspice.h b/src/include/ngspice.h index e18e35509..9f07956e3 100644 --- a/src/include/ngspice.h +++ b/src/include/ngspice.h @@ -131,7 +131,7 @@ struct timeb timebegin; #include "wstdio.h" #endif -#if defined (__MINGW32__) || defined (__CYGWIN__) +#if defined (__MINGW32__) || defined (__CYGWIN__) || defined (_MSC_VER) #include #else # ifdef HAVE_SYS_IO_H @@ -159,6 +159,10 @@ struct timeb timebegin; #define HUGE HUGE_VAL #endif +#if defined (_MSC_VER) +#define finite _finite +#endif + extern char *gettok(char **s); extern char *gettok_noparens(char **s); extern char *gettok_node(char **s); diff --git a/src/include/wstdio.h b/src/include/wstdio.h index 63c6b8a6e..cb9c5738a 100644 --- a/src/include/wstdio.h +++ b/src/include/wstdio.h @@ -43,7 +43,11 @@ int vfp_r_i_n_t_f(FILE * __stream, const char * __format, void * __arglist); /*int vfs_c_a_n_f(FILE * __stream, const char * __format, void * __arglist);*/ int vp_r_i_n_t_f(const char * __format, void * __arglist); /*int vs_c_a_n_f(const char * __format, void * __arglist); */ +#ifdef _MSC_VER +_CRTIMP int __cdecl read(int fd, _Out_bytecap_(_MaxCharCount) void * __buf, _In_ unsigned int __n); +#else int r_e_a_d(int fd, char * __buf, int __n); +#endif int g_e_t_c(FILE * __fp); int g_e_t_char(void); int p_u_t_char(const int __c); @@ -90,6 +94,14 @@ int fp_u_t_char(int __c); #define fgetchar fg_e_t_char #define fputchar fp_u_t_char +#if defined (_MSC_VER) +#define strdup _strdup +#define unlink _unlink +#define fileno _fileno +#define getcwd _getcwd +#define isnan _isnan +#endif + /*----------------------------------------------------------------------------*/ #endif /* WSTDIO_H */ diff --git a/src/spicelib/devices/bsim3soi/b4soild.c b/src/spicelib/devices/bsim3soi/b4soild.c index 8f41aa642..2ba0d16d4 100644 --- a/src/spicelib/devices/bsim3soi/b4soild.c +++ b/src/spicelib/devices/bsim3soi/b4soild.c @@ -18,6 +18,10 @@ #include "devdefs.h" #include "suffix.h" +#ifdef _MSC_VER +extern int _isnan(double); +#endif + #define EPSOX 3.453133e-11 #define EPSSI 1.03594e-10 #define Charge_q 1.60219e-19 diff --git a/src/spicelib/devices/hisim/hsm1eval102.c b/src/spicelib/devices/hisim/hsm1eval102.c index f0dbc9f6c..d4128c802 100644 --- a/src/spicelib/devices/hisim/hsm1eval102.c +++ b/src/spicelib/devices/hisim/hsm1eval102.c @@ -71,7 +71,9 @@ #ifdef HAVE_IEEEFP_H # include #endif - +#ifdef _MSC_VER +#define finite _finite +#endif /*-----------------------------------* * HiSIM macros and structures. * - All inputs and outputs are defined here. diff --git a/src/spicelib/devices/hisim/hsm1eval112.c b/src/spicelib/devices/hisim/hsm1eval112.c index 61dc2495d..8d3c88e65 100644 --- a/src/spicelib/devices/hisim/hsm1eval112.c +++ b/src/spicelib/devices/hisim/hsm1eval112.c @@ -71,6 +71,9 @@ #ifdef HAVE_IEEEFP_H # include #endif +#ifdef _MSC_VER +#define finite _finite +#endif /*-----------------------------------* * HiSIM macros and structures. diff --git a/src/spicelib/devices/hisim/hsm1eval120.c b/src/spicelib/devices/hisim/hsm1eval120.c index 9f24b10a0..f3c39a0c5 100644 --- a/src/spicelib/devices/hisim/hsm1eval120.c +++ b/src/spicelib/devices/hisim/hsm1eval120.c @@ -71,6 +71,9 @@ #ifdef HAVE_IEEEFP_H # include #endif +#ifdef _MSC_VER +#define finite _finite +#endif /*-----------------------------------* * HiSIM macros and structures.