04-22-2004 10:47 AM
04-23-2004 02:15 PM
04-24-2004 03:05 AM
10-05-2005 01:36 PM
That works great! Do you have some similar magic for GetDoubleEps and GetDoubleMin from float.h?
Thanks,
locolobo
10-05-2005 02:21 PM
10-05-2005 02:34 PM
I wish I could bring in the source, but it is "proprietary" and only being provided in a .lib.
As I was experimenting with a solution for the _GetDoubleMin, I noticed that the _GetFilesArray solution only seemed to work when the CVI stdio.h file was used for the compilation of the stub file. Is that the expected situation?
Thanks.
10-06-2005 09:56 AM
That is not the expected situation. It is intended to work with the MSVC version of stdio.h (at least, the 7.1 version of the compiler, if I remember correctly). But if you are having problems, this illustrates why creating these stubs is not ideal. They assume too much about how the particular target compiler that you are using implements these ANSI C symbols. The ANSI spec only requires that these particular symbols be available in the library, and also specifies their behavior, but does not specify how they should be implemented. These will work as long as you use the same compiler to compile and link the module. But if you change the compiler between the compilation stage and the linking stage, then problems can happen.
What happens is that each compiler ends up implementing these symbols in its own way, and those stubs are probably assuming too much about the implementation in a particular compiler.
I understand that in this particular case you do not have access to the source code, and that you need to build your project in a compiler other than CVI. If the .lib file was created by the CVI compiler, it will link just fine in CVI. Therefore, have you considered wrapping the exports you need from the .lib file into a DLL, that you can build in CVI, and then call from the project that you are building in the other compiler?
Luis
10-06-2005 10:09 AM
I think that I may have it working. I needed the 'extern "C"' to get past using the CVI stdio. I'm no longer getting linker errors, but I have yet to test the entire package to ensure that it all still works properly. Below is the code I am using. Feel free to comment.
#include "stdio.h"
#include "float.h"
#ifdef __cplusplus
extern "C" {
#endif
#ifndef _DBL_CONST_T
#define _DBL_CONST_T
typedef const union {
double val;
unsigned char a[8];
} _DoubleConst_t;
#endif
static FILE *wrapper_files[3] = {stdin, stdout, stderr};
static _DoubleConst_t DoubleMin = {DBL_MIN};
static _DoubleConst_t DoubleEps = {DBL_EPSILON};
FILE **_GetFilesArray (void)
{
return wrapper_files;
}
_DoubleConst_t *_GetDoubleMin (void)
{
return &DoubleMin;
}
_DoubleConst_t *_GetDoubleEps (void)
{
return &DoubleEps;
}
#ifdef __cplusplus
}
#endif
10-06-2005 01:47 PM
01-26-2008 01:49 PM