From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Signal Conditioning

cancel
Showing results for 
Search instead for 
Did you mean: 

Borland C++ Builder compiling problem with Component Works V6

I receive an error compiling with Borland C++ Builder V3, V4 or V5 with Component Works V6 Active X Controls. For example, when I use TCWGraph Active X control I receive the following compiler error shown
below. I created a variant variable but cannot pass it without an error to the Active X Control. I have also used the C++ Builder example codes posted in the Knowledge Base (CWGraph and CWSerial examples) resulting in the same compiler problem. What do you
suggest to correct the compilation error? Thanks.

================ERROR=============================
[C++ Error] Unit1.cpp(41): E2015 Ambiguity between '_fastcall Variant::operator TVariant()' and 'TVariant::TVariantT(const Variant &)'
0 Kudos
Message 1 of 3
(4,973 Views)
The solution is to use the TVariantT structure which wraps a Windows VARIANT structure around VARIANT. TVariantT and TVariant are used to represent COM arguments and interfaces, just like the OleVariant class. However, TVariantT and TVariant are designed to work with C++Builder’s COM implementation classes that use the ATL, while OleVariant works with the VCL’s COM support.

The code to use for Borland's C++ Builder V4 for the TCWGraph example is the following:

TVariantT <(float)VARIANT> VarT2[100];

Variant vMean, vStdDev;
Variant data(OPENARRAY(int,(0,99)),varDouble);

int Bounds[2] = {0,99};
Variant A = VarArrayCreate(Bounds,1, varVariant);

int i;
for (i=0;i<100;i++) A.PutElement(rand()/10000.0,i);

//******TVariantT& operator
=(VARIANT& src)********
VarT2[0] = (VARIANT&) A;

CWGraph1->ClearData();
CWGraph1->PlotY(VarT2[0], 0, 1, true);
CWStat1->StdDev(VarT2[0], vMean, vStdDev);
MeanVal->Value = vMean;
StdDevVal->Value = vStdDev;
0 Kudos
Message 2 of 3
(4,973 Views)
I try this solution by coding them in a infinite loop and run it over two hours, it seems to has memory leakage because when I click "my computer" icon on the desktop I got an "not enoungh memory" message. Does anyone has any suggestion to get around this problem?
(My environment is Builder 5.0, Win2000 sp3.)

TVariantT <(float)VARIANT> VarT2[100];
int Bounds[2] = {0,99};
Variant A = VarArrayCreate( Bounds, 1, varVariant);
int i;
for ( i=0; i<100; i++) A.PutElement(rand()/10000.0,i);
//******TVariantT& operator =(VARIANT& src)********
VarT2[0] = (VARIANT&)A;

while( !isStop){
Application->ProcessMessages();
CWGraphDigitize->ClearData();
CWGraphDigitize->PlotY( VarT2[0], 0, 1, true);
Application->ProcessMessages();

CWGraphSpectrum->ClearData();
CWGraphSpectrum->PlotY( VarT2[0], 0, 1, true);
}
0 Kudos
Message 3 of 3
(4,973 Views)