-1

I am attempting to port some code from a a visual studio project to mingw. The compiler is pointing out an undefined reference error in which it assumes the second parameter is a wchar_t const*. I have both _UNICODE and UNICODE defined in my project

undefined reference to `CBaseVideoRenderer::CBaseVideoRenderer(_GUID const&, wchar_t const*, IUnknown*, long*)'

Here is the code I am using

The constructor of the base class is this

  CBaseVideoRenderer(REFCLSID RenderClass,LPCTSTR pName, LPUNKNOWN pUnk,      
                        HRESULT *phr);  

This is how its being initiated in the base class

MemRenderer::MemRenderer(LPUNKNOWN ptr, HRESULT *hr, OutputBuffer *buffer)
    : CBaseVideoRenderer(__uuidof(CLSID_MemRenderer), NAME("MemRenderer"), ptr, hr)

Now I am getting the error on the above statment saying

  undefined reference to `CBaseVideoRenderer::CBaseVideoRenderer(_GUID const&, wchar_t const*, IUnknown*, long*)'

My question is why am I getting that error ? I looked up LPCTSTR and it seems to be a constant char pointer so I tried this too

 MemRenderer::MemRenderer(LPUNKNOWN ptr, HRESULT *hr, OutputBuffer *buffer)
        : CBaseVideoRenderer(__uuidof(CLSID_MemRenderer), "MemRenderer", ptr, hr)

However I get the error

error: no matching function for call to 'CBaseVideoRenderer::CBaseVideoRenderer(const GUID&, const char [12], IUnknown*&, HRESULT*&)'
    buffer(buffer)

Any suggestions on how I can fix this issue ?

MistyD
  • 16,373
  • 40
  • 138
  • 240
  • See this: http://stackoverflow.com/questions/28639114/porting-stdwstring-from-visual-studio-to-mingw-gcc – Chad Apr 07 '15 at 18:12
  • The `NAME("MemRenderer")` was accurate, the error was a _linker_ error. Your code is fine. – Mooing Duck Apr 07 '15 at 18:22
  • Wait, why is `hr` a `long*` in one code, and a `HRESULT*` in the other? Also, normally a result named `hr` is a `HRESULT`, and you would pass it by pointer: `&hr`. – Mooing Duck Apr 07 '15 at 18:23
  • 1
    `CBaseVideoRenderer(REFCLSID RenderClass,LPCTSTR pName, LPUNKNOWN pUnk, HRESULT *phr);` is a declaration. I don't suppose you have an *implementation* somewhere to go with that? – WhozCraig Apr 07 '15 at 18:24

1 Answers1

1

The definition of LPCTSTR depends on whether UTF-16 unicode is enabled as default character type or not.

THis has an impact on litterals:

  • "xxx" can be used if no unicode is used.
  • L"xxx" is to be used if unicode is used

You can find more on the types to be used here.

Christophe
  • 68,716
  • 7
  • 72
  • 138
  • Thanks for clearing that up. The NAME macro was not working for some reason and putting an L did the trick – MistyD Apr 07 '15 at 18:23