An unexplained compiler error (C2039)
-
hey, i get a very strange compilation error when compiling these files in .net : //message.h class Message { public: void GetMessage(); }; //message.cpp #include "message.h" void Message::GetMessage() { } //point.h #include "message.h" class Point { Message m; public: void ShowMessage(); }; //point.cpp #include "point.h" #include void Point::ShowMessage() { m.GetMessage(); } void main() { } i get this error: d:\point.cpp(8) : error C2039: 'GetMessageA' : is not a member of 'Message' d:\test\message.h(4) : see declaration of 'Message' as you can see there is indeed no function named GetMessageA but i wrote GetMessage , where did this A come from?!? if i don't including Winsock2.h everything works fine. what does Winsock2.h have to do with it?
-
hey, i get a very strange compilation error when compiling these files in .net : //message.h class Message { public: void GetMessage(); }; //message.cpp #include "message.h" void Message::GetMessage() { } //point.h #include "message.h" class Point { Message m; public: void ShowMessage(); }; //point.cpp #include "point.h" #include void Point::ShowMessage() { m.GetMessage(); } void main() { } i get this error: d:\point.cpp(8) : error C2039: 'GetMessageA' : is not a member of 'Message' d:\test\message.h(4) : see declaration of 'Message' as you can see there is indeed no function named GetMessageA but i wrote GetMessage , where did this A come from?!? if i don't including Winsock2.h everything works fine. what does Winsock2.h have to do with it?
Change the GetMessage function to another name and see what happens. Maybe it gets stacked when trying to access to GetMessage because it thinks that it may access to GetMessageA.
Written by: Rafael Fernández López.
-
hey, i get a very strange compilation error when compiling these files in .net : //message.h class Message { public: void GetMessage(); }; //message.cpp #include "message.h" void Message::GetMessage() { } //point.h #include "message.h" class Point { Message m; public: void ShowMessage(); }; //point.cpp #include "point.h" #include void Point::ShowMessage() { m.GetMessage(); } void main() { } i get this error: d:\point.cpp(8) : error C2039: 'GetMessageA' : is not a member of 'Message' d:\test\message.h(4) : see declaration of 'Message' as you can see there is indeed no function named GetMessageA but i wrote GetMessage , where did this A come from?!? if i don't including Winsock2.h everything works fine. what does Winsock2.h have to do with it?
onece, I also encountered this problem, finally, all went well. your code above can be compiled without any error, but if you add some other initialization into one class A(it includes "1.h"), the other class B's implementation file must also include "1.h" for the implementation of object of A in the file.
-
onece, I also encountered this problem, finally, all went well. your code above can be compiled without any error, but if you add some other initialization into one class A(it includes "1.h"), the other class B's implementation file must also include "1.h" for the implementation of object of A in the file.
Well I was pretty sure that the code above was right !! Ok then !! ;)
Written by: Rafael Fernández López.
-
hey, i get a very strange compilation error when compiling these files in .net : //message.h class Message { public: void GetMessage(); }; //message.cpp #include "message.h" void Message::GetMessage() { } //point.h #include "message.h" class Point { Message m; public: void ShowMessage(); }; //point.cpp #include "point.h" #include void Point::ShowMessage() { m.GetMessage(); } void main() { } i get this error: d:\point.cpp(8) : error C2039: 'GetMessageA' : is not a member of 'Message' d:\test\message.h(4) : see declaration of 'Message' as you can see there is indeed no function named GetMessageA but i wrote GetMessage , where did this A come from?!? if i don't including Winsock2.h everything works fine. what does Winsock2.h have to do with it?
Some windows include files
#define
certain things so that you only write code once and it expands the function names out to the correct form.GetMessageA
(IIRC) means it is the Ascii (or Ansi) version ofGetMessage
while if you set some compiler option your error message will change toGetMessageW
(which is the Wide character version of the function). This way you can write compile the code for ASCII and then recompile the same code and get a Wide character version which will allow better internationalisation. If you#include
the winsock2.h on all your files they will all get expanded out to GetMessageA and all will work, if you don't want that to happen then choose a different method name.
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar Coming soon: The Second EuroCPian Event
-
hey, i get a very strange compilation error when compiling these files in .net : //message.h class Message { public: void GetMessage(); }; //message.cpp #include "message.h" void Message::GetMessage() { } //point.h #include "message.h" class Point { Message m; public: void ShowMessage(); }; //point.cpp #include "point.h" #include void Point::ShowMessage() { m.GetMessage(); } void main() { } i get this error: d:\point.cpp(8) : error C2039: 'GetMessageA' : is not a member of 'Message' d:\test\message.h(4) : see declaration of 'Message' as you can see there is indeed no function named GetMessageA but i wrote GetMessage , where did this A come from?!? if i don't including Winsock2.h everything works fine. what does Winsock2.h have to do with it?
GetMessage is a #define for GetMessageA or GetMessageW depending on wheather you are using unicode or not... you should declare a method name that is already defined by windows, instead chose some other name.
I'll write a suicide note on a hundred dollar bill - Dire Straits
-
GetMessage is a #define for GetMessageA or GetMessageW depending on wheather you are using unicode or not... you should declare a method name that is already defined by windows, instead chose some other name.
I'll write a suicide note on a hundred dollar bill - Dire Straits