VS 2014 question, have I found a problem.

  • Thread starter Thread starter Paul D. Schwartz
  • Start date Start date
P

Paul D. Schwartz

Guest
I don't know if this is the proper place to post this question as it pertains to Visual Studio Pro 2014 CTP, but here goes . . .

The warning in question is new with the installation of VS2014 CTP. I am developing an application with COM interfaces and I am getting a compiler warning and it has to do with the following code.

I have a typical QueryInterface call which is the following:

IFACEMETHODIMP QueryInterface(__in REFIID riid, __deref_out void **ppv)
{
static const QITAB qit[] =
{
QITABENT(CClassFactory, IClassFactory),
{ 0 },
};
return QISearch(this, qit, riid, ppv);
}

The exact warning is:warning C4838: conversion from 'DWORD' to 'int' requires a narrowing conversion.

Near as I can tell the warning comes from the definition of QITAB as the following:

typedef struct
{
const IID * piid;
int dwOffset;
} QITAB, *LPQITAB;

Note that dwOffset is defined as an int and QITAB is defined in the header shlwapi.h.

Now, QITABENT is also defined in the header shlwapi.h as

QITABENT(Cthis, Ifoo) QITABENTMULTI(Cthis, Ifoo, Ifoo)

If you follow the definition QITABENT deep enough you finally arrive at OFFSETOFCLASS which is defined as

((DWORD)(DWORD_PTR)(STATIC_CAST(base*)((derived*)8))-8)

So it seems to me the visual studio 2014 compiler is looking for a DWORD and gets the int for dwOffset.

So my question is... can i ignore this warning without concern (By disabling it), or is this a real problem?

Thanks

Paul







Greetings From Tralfamador.

Continue reading...
 
Back
Top