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
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Can not find where to define an identifier..

Can not find where to define an identifier..

Scheduled Pinned Locked Moved C / C++ / MFC
c++helpdebuggingtoolslearning
15 Posts 3 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.
  • C Carbonkevlar13

    Hello i am a total newbie in C++ and i am learning by tryning to modify an existing code which uses displays. In the original code there are 2 displays showing informations to the user I want to add a third display do i copied the screen2.cpp and screen2.h and renamed them to screen3.cpp and screen3.h Inside the screen3 code i replace all mentions of screen2 by screen3 and i added the screen 3 in the screens.cpp script // User screens MMIRegisterScreen(SCREENID_1, Screen1Enter, Screen1Create, Screen1Update, Screen1Exit); MMIRegisterScreen(SCREENID_2, Screen2Enter, Screen2Create, Screen2Update, Screen2Exit); MMIRegisterScreen(SCREENID_3, Screen3Enter, Screen3Create, Screen3Update, Screen3Exit); My problem is that when i debug i end up with 4 error messages as the Screen3Enter, Screen3Create , Screen3Update and Screen3Exit are not declared This is strange as in the screen3.cpp the functions here above are declared the same way they are declared for the other screen i copied from void Screen3Enter(void) { } void Screen3Create(void) { Thanks for your suggestions

    C Offline
    C Offline
    CPallini
    wrote on last edited by
    #3

    You have to find where

    Screen2Enter, Screen2Create, Screen2Update, Screen2Exit

    are declared (and where they are defined) and do something similar to what you've already done: make the brand new

    Screen3Enter, Screen3Create, Screen3Update, Screen3Exit

    copying and renaming. Unfortunately the process could go on deeper and deeper.

    "In testa che avete, Signor di Ceprano?" -- Rigoletto

    C 1 Reply Last reply
    0
    • C CPallini

      You have to find where

      Screen2Enter, Screen2Create, Screen2Update, Screen2Exit

      are declared (and where they are defined) and do something similar to what you've already done: make the brand new

      Screen3Enter, Screen3Create, Screen3Update, Screen3Exit

      copying and renaming. Unfortunately the process could go on deeper and deeper.

      "In testa che avete, Signor di Ceprano?" -- Rigoletto

      C Offline
      C Offline
      Carbonkevlar13
      wrote on last edited by
      #4

      Thanks the functions are defined in the script of the screen I am wondering if they should be declared somewhere else ? void Screen3Enter(void) { } void Screen3Create(void) { // Setup default keys ScreensSetupDefaultKeys();

      C L 2 Replies Last reply
      0
      • L Lost User

        No one here can guess what this code is doing, or what it is supposed to do. And trying to learn C++ by modifying someone else's code is not a great idea.

        C Offline
        C Offline
        Carbonkevlar13
        wrote on last edited by
        #5

        OK thanks but i have no time to learn from scratch I have an existing code doing more or less what i expect on the displays and am trying to make it look how i want.

        L 1 Reply Last reply
        0
        • C Carbonkevlar13

          OK thanks but i have no time to learn from scratch I have an existing code doing more or less what i expect on the displays and am trying to make it look how i want.

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #6

          Carbonkevlar13 wrote:

          i have no time to learn from scratch

          Then you are going to need a lot of luck, and will probably get very frustrated. Looking at the few lines of code you did show suggests that it is a Windows GUI application, so that is another subject you will need to learn.

          1 Reply Last reply
          0
          • C Carbonkevlar13

            Thanks the functions are defined in the script of the screen I am wondering if they should be declared somewhere else ? void Screen3Enter(void) { } void Screen3Create(void) { // Setup default keys ScreensSetupDefaultKeys();

            C Offline
            C Offline
            CPallini
            wrote on last edited by
            #7

            In C++ there is no script. There are, instead, header files (*.h) and source files (usually *.cpp or *.cc). You should put the function declarations, e.g.

            void Screen3Enter();

            in header files, while the function definitions, e.g.

            void Screen3Enter()
            {
            // some useful code here
            }

            should be written in source files.

            "In testa che avete, Signor di Ceprano?" -- Rigoletto

            C 1 Reply Last reply
            0
            • C CPallini

              In C++ there is no script. There are, instead, header files (*.h) and source files (usually *.cpp or *.cc). You should put the function declarations, e.g.

              void Screen3Enter();

              in header files, while the function definitions, e.g.

              void Screen3Enter()
              {
              // some useful code here
              }

              should be written in source files.

              "In testa che avete, Signor di Ceprano?" -- Rigoletto

              C Offline
              C Offline
              Carbonkevlar13
              wrote on last edited by
              #8

              Thanks i already have these declarations inside screens3.cpp void Screen3Enter(void) void Screen3Create(void) void Screen3Update(void) void Screen3Exit(void) when i am inside screens3.cpp there is a "No issues found" message at the bottom of the screen but when i launch the simulation i have these 4 error messages C2065 'Screen3Enter' undeclared identifier from the screens.cpp source referring to the following line MMIRegisterScreen(SCREENID_3, Screen3Enter, Screen3Create, Screen3Update, Screen3Exit); Thanks for trying to help me

              C 1 Reply Last reply
              0
              • C Carbonkevlar13

                Thanks i already have these declarations inside screens3.cpp void Screen3Enter(void) void Screen3Create(void) void Screen3Update(void) void Screen3Exit(void) when i am inside screens3.cpp there is a "No issues found" message at the bottom of the screen but when i launch the simulation i have these 4 error messages C2065 'Screen3Enter' undeclared identifier from the screens.cpp source referring to the following line MMIRegisterScreen(SCREENID_3, Screen3Enter, Screen3Create, Screen3Update, Screen3Exit); Thanks for trying to help me

                C Offline
                C Offline
                CPallini
                wrote on last edited by
                #9

                Put those declarations inside the screens3.h header file. For instance:

                // screens3.h
                #ifndef _SCREENS3_
                #define _SCREENS3_
                void Screen3Enter(void);
                void Screen3Create(void);
                void Screen3Update(void);
                void Screen3Exit(void);
                #endif

                then put

                #include "screens3.h"

                in every source file that needs them (e.g. screens.cpp)

                "In testa che avete, Signor di Ceprano?" -- Rigoletto

                C 1 Reply Last reply
                0
                • C CPallini

                  Put those declarations inside the screens3.h header file. For instance:

                  // screens3.h
                  #ifndef _SCREENS3_
                  #define _SCREENS3_
                  void Screen3Enter(void);
                  void Screen3Create(void);
                  void Screen3Update(void);
                  void Screen3Exit(void);
                  #endif

                  then put

                  #include "screens3.h"

                  in every source file that needs them (e.g. screens.cpp)

                  "In testa che avete, Signor di Ceprano?" -- Rigoletto

                  C Offline
                  C Offline
                  Carbonkevlar13
                  wrote on last edited by
                  #10

                  I added #include "screens3.h" in different source files although it was not for the other screens When i launched the simulator there was an error message saying "cannot open source file screen3.h" I tried to retype MMIRegisterScreen instead of copying it and when i started to type the first function (screen3Enter) it proposed different functions to me but none for the screen 3 although they qre declared inside the screen3.cpp I deleted the screen3Enter function and retyped it hoping to see it appear in the list of proposed functions for the MMURefusterScreen but still it was not in the list

                  C 1 Reply Last reply
                  0
                  • C Carbonkevlar13

                    Thanks the functions are defined in the script of the screen I am wondering if they should be declared somewhere else ? void Screen3Enter(void) { } void Screen3Create(void) { // Setup default keys ScreensSetupDefaultKeys();

                    L Offline
                    L Offline
                    Lost User
                    wrote on last edited by
                    #11

                    As I said earlier, it is impossible to guess without more information. Just showing a couple of random lnes of code gives no real idea of what is missing.

                    1 Reply Last reply
                    0
                    • C Carbonkevlar13

                      I added #include "screens3.h" in different source files although it was not for the other screens When i launched the simulator there was an error message saying "cannot open source file screen3.h" I tried to retype MMIRegisterScreen instead of copying it and when i started to type the first function (screen3Enter) it proposed different functions to me but none for the screen 3 although they qre declared inside the screen3.cpp I deleted the screen3Enter function and retyped it hoping to see it appear in the list of proposed functions for the MMURefusterScreen but still it was not in the list

                      C Offline
                      C Offline
                      CPallini
                      wrote on last edited by
                      #12

                      Quote:

                      I added #include "screens3.h" in different source

                      Quote:

                      there was an error message saying "cannot open source file screen3.h"

                      can you spot the difference?

                      "In testa che avete, Signor di Ceprano?" -- Rigoletto

                      C 1 Reply Last reply
                      0
                      • C CPallini

                        Quote:

                        I added #include "screens3.h" in different source

                        Quote:

                        there was an error message saying "cannot open source file screen3.h"

                        can you spot the difference?

                        "In testa che avete, Signor di Ceprano?" -- Rigoletto

                        C Offline
                        C Offline
                        Carbonkevlar13
                        wrote on last edited by
                        #13

                        yes i removed the s from screens3 but no change finally what i did is modify a fourth screen already programmed with a gauge to benefit from the declarations and it works.. I still do not understand why it did not work with my screen. Thanks for your help !

                        C L 2 Replies Last reply
                        0
                        • C Carbonkevlar13

                          yes i removed the s from screens3 but no change finally what i did is modify a fourth screen already programmed with a gauge to benefit from the declarations and it works.. I still do not understand why it did not work with my screen. Thanks for your help !

                          C Offline
                          C Offline
                          CPallini
                          wrote on last edited by
                          #14

                          You are welcome.

                          "In testa che avete, Signor di Ceprano?" -- Rigoletto

                          1 Reply Last reply
                          0
                          • C Carbonkevlar13

                            yes i removed the s from screens3 but no change finally what i did is modify a fourth screen already programmed with a gauge to benefit from the declarations and it works.. I still do not understand why it did not work with my screen. Thanks for your help !

                            L Offline
                            L Offline
                            Lost User
                            wrote on last edited by
                            #15

                            Carbonkevlar13 wrote:

                            I still do not understand why it did not work with my screen.

                            So look carefully at all the other code and compare it line by line with the code that you made.

                            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