0

I have the following code:

// --- message_queue.hpp ---
namespace vca {
namespace keystone {
namespace messaging {
class VCA_KEYSTONE_DLL_PUBLIC MessageQueue final {
  [...]
  Message PeekMessage();  // <-- Declaration
  [...]
};
}  // namespace messaging
}  // namespace keystone
}  // namespace vca

// --- message_queue.cpp ---
namespace vca {
namespace keystone {
namespace messaging {
Message MessageQueue::PeekMessage() {  // <-- Definition
  [...]
}
}  // namespace messaging
}  // namespace keystone
}  // namespace vca

I get the following strange error from MinGW-builds-4.8.1-x64-posix-seh:

..\..\lib\messaging\src\message_queue.cpp:281:35: error: no
'vca::keystone::messaging::Message vca::keystone::messaging::MessageQueue::PeekMessageA()'
 member function declared in class 'vca::keystone::messaging::MessageQueue'
 Message MessageQueue::PeekMessage() {
                                  ^

The thing that confuses me is why it is saying the PeekMessageA() function doesn't exist, where did the A come from?

If I remove the definition, it will compile and I will get the expected linker errors:

lib\messaging\src\task.cpp.1.o: In function
  `vca::keystone::messaging::Task::TaskImpl::PeekMessageA()':
    ../../lib/messaging/src/task.cpp:939:
    undefined reference to `vca::keystone::messaging::MessageQueue::PeekMessageA()'
collect2.exe: error: ld returned 1 exit status

This shows that the A is added to the Task::TaskImpl::PeekMessageA. What is this A and why is gcc not finding the compiling the correct symbol when I build my file?

4

1 回答 1

2

The Windows API provides two versions of many functions, one for A NSI-encoded and one for W ide strings. Typically, a compiler option and set of header macros will map the undecorated names to either of the two versions, as well as provide suitable definitons ofthe TEXT and _T macros.

于 2013-09-25T10:14:34.720 回答