03-31-2008 08:24 AM
04-01-2008 08:50 AM
This kind of redeclaration error is a frequent problem when mixing different C libraries - they export functions of the same name and this results in compile (*not* link) errors. The common solution to this problem is to redeclare the conflicting functions after including the first file and before including the second, as follows:
#include <extcode.h>
#define Pin LVPin
#define SwapBlock LVSwapBlock
#define BinSearch LVBinSearch
#include <toolbox.h>
Neither LabVIEW nor CVI can workaround this without dropping support for these functions, breaking backwards compatibility, etc. This is one good reason to prefix C functions with some kind of 'namespace' qualifier - like 'MyLib_'.
04-01-2008 09:07 AM
#include <extcode.h>
#define Pin CVIPin
#define SwapBlock CVISwapBlock
#define BinSearch CVIBinSearch
#include <toolbox.h>
/* OR */
#define Pin LVPin
#define SwapBlock LVSwapBlock
#define BinSearch LVBinSearch
#include <extcode.h>
#undef Pin
#undef SwapBlock
#undef BinSearch
#include <toolbox.h>
04-01-2008 09:32 AM
Thanks a lot! I was just wondering about my understanding of C preprocessor defines.
@Mohan wrote:Better,#include
#define Pin CVIPin
#define SwapBlock CVISwapBlock
#define BinSearch CVIBinSearch
#include/* OR */
#define Pin LVPin
#define SwapBlock LVSwapBlock
#define BinSearch LVBinSearch
#include
#undef Pin
#undef SwapBlock
#undef BinSearch#include
Of course, there is no need to copy or edit the include files - which is not a good idea, anyway.