1

I think there is a possible conflict between a method and a windows macro. I am using cygwin gcc and this is what my conflict looks like

File : MRepository.h
#pragma once

#ifdef  GetMessage
#undef  GetMessage
#endif  //GetMessage

class MRepository
{
public:

    std::wstring GetMessage(const std::wstring &key) const;
    ...
    ....

};

File : MRepository.cpp
bool MRepository::SomeMethod(boost::shared_ptr<foo> &nd)
{
        std::wstring type = this->GetMessage(L"SomeData"); //Error Here : Method not recognized
        ....
        ....        
    return available;
}

This is the error that I get from the method

error: 'class MRepository' has no member named 'GetMessageA'|

Notice that I called GetMessage but it thinks the method is called GetMessageA any suggestions on why the compiler thinks I am trying to reference GetMessageA when I clearly typed in GetMessage ?

Rajeshwar
  • 11,179
  • 26
  • 86
  • 158
  • That's a Windows thing it does for methods for Unicode support. GetMessageA() is the ANSI version where GetMessageW() would be the wide string version. – Steven Behnke Jan 28 '15 at 21:52
  • I am not calling `GetMessageA` I am trying to call my own method called 'GetMessage` – Rajeshwar Jan 28 '15 at 21:53
  • windows.h has an enormous number of macros that define FuncThing as FuncThingA or FuncThingW depending on whether or not UNICODE is defined – pm100 Jan 28 '15 at 21:56
  • I realize you're not calling it, but Windows.h has a system method called GetMessage(). Try renaming it and see that it works fine. Or don't include Windows.h – Steven Behnke Jan 28 '15 at 21:57

1 Answers1

1

The best solution I've found is to just rename your methods to things that don't clash with the windows macros.

You will probably find in the .cpp at the point of call that the macro for GetMessage is in-effect.

Scott Langham
  • 58,735
  • 39
  • 131
  • 204