Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. An unexplained compiler error (C2039)

An unexplained compiler error (C2039)

Scheduled Pinned Locked Moved C / C++ / MFC
csharpc++helpquestion
7 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Anonymous
    wrote on last edited by
    #1

    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?

    R G C P 4 Replies Last reply
    0
    • A Anonymous

      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?

      R Offline
      R Offline
      Rafael Fernandez Lopez
      wrote on last edited by
      #2

      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.

      Visit: http://www.maestroprogramador.com

      1 Reply Last reply
      0
      • A Anonymous

        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?

        G Offline
        G Offline
        GavinWang
        wrote on last edited by
        #3

        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.

        R 1 Reply Last reply
        0
        • G GavinWang

          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.

          R Offline
          R Offline
          Rafael Fernandez Lopez
          wrote on last edited by
          #4

          Well I was pretty sure that the code above was right !! Ok then !! ;)


          Written by: Rafael Fernández López.

          Visit: http://www.maestroprogramador.com

          1 Reply Last reply
          0
          • A Anonymous

            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?

            C Offline
            C Offline
            Colin Angus Mackay
            wrote on last edited by
            #5

            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 of GetMessage while if you set some compiler option your error message will change to GetMessageW (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

            1 Reply Last reply
            0
            • A Anonymous

              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?

              P Offline
              P Offline
              Prakash Nadar
              wrote on last edited by
              #6

              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

              A 1 Reply Last reply
              0
              • P Prakash Nadar

                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

                A Offline
                A Offline
                Anonymous
                wrote on last edited by
                #7

                thanks for all your answers. what i still don't understand is how is one supose to know what excaly are the functions "already defined by windows" in order to avoid reusing their names...

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups