Browse Source

type fix for Visual Studio

rlar 15 years ago
parent
commit
94a4e45d08
  1. 4
      ChangeLog
  2. 18
      src/spicelib/devices/dev.c

4
ChangeLog

@ -1,3 +1,7 @@
2011-08-05 Robert Larice
* src/spicelib/devices/dev.c :
type fix for Visual Studio
2011-08-05 Robert Larice 2011-08-05 Robert Larice
* src/include/ngspice.h : * src/include/ngspice.h :
disable Visual Studio "warning: C4127: conditional expression is constant" disable Visual Studio "warning: C4127: conditional expression is constant"

18
src/spicelib/devices/dev.c

@ -50,9 +50,12 @@
#include <windows.h> #include <windows.h>
#ifdef HAS_WINDOWS #ifdef HAS_WINDOWS
#include "wstdio.h" #include "wstdio.h"
typedef FARPROC funptr_t;
#else
typedef void * funptr_t;
#endif #endif
void *dlopen (const char *, int); void *dlopen (const char *, int);
void *dlsym (void *, const char *);
funptr_t dlsym (void *, const char *);
int dlclose (void *); int dlclose (void *);
char *dlerror (void); char *dlerror (void);
#define RTLD_LAZY 1 /* lazy function call binding */ #define RTLD_LAZY 1 /* lazy function call binding */
@ -302,7 +305,7 @@ int load_dev(char *name) {
char *msg; char *msg;
char libname[50]; char libname[50];
void *lib; void *lib;
SPICEdev *(*fetch)(void)=NULL;
funptr_t fetch;
SPICEdev *device; SPICEdev *device;
strcpy(libname, "lib"); strcpy(libname, "lib");
@ -326,7 +329,7 @@ int load_dev(char *name) {
printf("%s\n", msg); printf("%s\n", msg);
return 1; return 1;
} }
device = fetch();
device = ((SPICEdev * (*)(void)) fetch) ();
add_device(1,&device,0); add_device(1,&device,0);
return 0; return 0;
} }
@ -406,7 +409,7 @@ int load_opus(char *name){
struct coreInfo_t **core; struct coreInfo_t **core;
SPICEdev **devs; SPICEdev **devs;
Evt_Udn_Info_t **udns; Evt_Udn_Info_t **udns;
void *fetch = NULL;
funptr_t fetch;
lib = dlopen(name,RTLD_NOW); lib = dlopen(name,RTLD_NOW);
if(!lib){ if(!lib){
@ -421,7 +424,6 @@ int load_opus(char *name){
#ifdef TRACE #ifdef TRACE
printf("Got %u devices.\n",*num); printf("Got %u devices.\n",*num);
#endif #endif
fetch = NULL;
}else{ }else{
msg = dlerror(); msg = dlerror();
printf("%s\n", msg); printf("%s\n", msg);
@ -431,7 +433,6 @@ int load_opus(char *name){
fetch = dlsym(lib,"CMdevs"); fetch = dlsym(lib,"CMdevs");
if(fetch){ if(fetch){
devs = ((SPICEdev ** (*)(void)) fetch) (); devs = ((SPICEdev ** (*)(void)) fetch) ();
fetch = NULL;
}else{ }else{
msg = dlerror(); msg = dlerror();
printf("%s\n", msg); printf("%s\n", msg);
@ -442,7 +443,6 @@ int load_opus(char *name){
if(fetch){ if(fetch){
core = ((struct coreInfo_t ** (*)(void)) fetch) (); core = ((struct coreInfo_t ** (*)(void)) fetch) ();
*core = &coreInfo; *core = &coreInfo;
fetch = NULL;
}else{ }else{
msg = dlerror(); msg = dlerror();
printf("%s\n", msg); printf("%s\n", msg);
@ -456,7 +456,6 @@ int load_opus(char *name){
#ifdef TRACE #ifdef TRACE
printf("Got %u udns.\n",*num); printf("Got %u udns.\n",*num);
#endif #endif
fetch = NULL;
}else{ }else{
msg = dlerror(); msg = dlerror();
printf("%s\n", msg); printf("%s\n", msg);
@ -466,7 +465,6 @@ int load_opus(char *name){
fetch = dlsym(lib,"CMudns"); fetch = dlsym(lib,"CMudns");
if(fetch){ if(fetch){
udns = ((Evt_Udn_Info_t ** (*)(void)) fetch) (); udns = ((Evt_Udn_Info_t ** (*)(void)) fetch) ();
fetch = NULL;
}else{ }else{
msg = dlerror(); msg = dlerror();
printf("%s\n", msg); printf("%s\n", msg);
@ -486,7 +484,7 @@ void *dlopen(const char *name,int type)
return LoadLibrary(name); return LoadLibrary(name);
} }
void *dlsym(void *hDll, const char *funcname)
funptr_t dlsym(void *hDll, const char *funcname)
{ {
return GetProcAddress(hDll, funcname); return GetProcAddress(hDll, funcname);
} }

Loading…
Cancel
Save