Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VARIANT_BOOL vs. BOOL

Tags:

c++

com

I am writing a COM object in C++ using ATL and am not sure whether I should be using VARIANT_BOOL for my methods/properties or not. The object will be called by other C++ apps but I cannot rule out usage from .NET.

I can stick to good old BOOL (which IIRC is simply an unsigned int) but as VARIANT_BOOL is there, shouldn't I be using it? If I do use it, and call these methods from a C++ app, I have to add extra code as a VARIANT_BOOL is not like a 'normal' boolean and I have to check for VARIANT_TRUE and VARIANT_FALSE values.

Is VARIANT_BOOL an anachronism that I can forget or should I stick with it?

like image 860
Rob Avatar asked Nov 18 '08 20:11

Rob


1 Answers

VARIANT_BOOL will make your COM component VB6 friendly. COM never really seemed to be made for doing things simply in C++, but more focus on making it easy to use from VB. Not sure if this still applies to .net access of a COM component or not.

like image 62
crashmstr Avatar answered Oct 18 '22 08:10

crashmstr