Search code examples
c++combstr

_bstr_t Not a known identifier


I've been using this class for years and it's always "just there". I created a new project the other day and without explicitly doing anything, this class was available.

Now another new project complains it is not known. Both projects have the same #includes.

Neither project #includes comutil.h. Neither project uses the commsuppw.lib library (https://msdn.microsoft.com/en-us/library/zthfhkd6(v=vs.110).aspx). The only possibly related header included is objbase.h, which both projects include.

So why does one project build happily and the other doesn't? How is the one that works able to link without the needed library?

I think this is one of those "I've been coding all day and my brain has stopped working issues" but still... what?


Solution

  • I needed to #include <comdef.h>

    Apparently this automagically imports the required libs.