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. undeclared identifier "class"

undeclared identifier "class"

Scheduled Pinned Locked Moved C / C++ / MFC
helpdatabasequestion
18 Posts 4 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.
  • V Offline
    V Offline
    VonHagNDaz
    wrote on last edited by
    #1

    hey guys, I'm having a problem with a project I'm working on. When I compile my project, I get a "undeclared identifier "class" error. ***no includes(not part of code)*** class TME_BasicParameters { public: * values taken from the basic programming screen */ float torqueHighLim; float turnOffStage2; float torqueLowLim; float startAngle; float turnOffStage1; float trigger; float stage1Speed; float angleLowLim; float turnOffAngle; float angleHighLim; float stage2Speed; float backoff; int strategy; int app; int tool; }; :confused: any ideas?

    D S 2 Replies Last reply
    0
    • V VonHagNDaz

      hey guys, I'm having a problem with a project I'm working on. When I compile my project, I get a "undeclared identifier "class" error. ***no includes(not part of code)*** class TME_BasicParameters { public: * values taken from the basic programming screen */ float torqueHighLim; float turnOffStage2; float torqueLowLim; float startAngle; float turnOffStage1; float trigger; float stage1Speed; float angleLowLim; float turnOffAngle; float angleHighLim; float stage2Speed; float backoff; int strategy; int app; int tool; }; :confused: any ideas?

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      VonHagNDaz wrote:

      When I compile my project, I get a "undeclared identifier "class" error.

      What line of what file is the compiler complaining about?

      "Love people and use things, not love things and use people." - Unknown

      "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

      V 1 Reply Last reply
      0
      • D David Crow

        VonHagNDaz wrote:

        When I compile my project, I get a "undeclared identifier "class" error.

        What line of what file is the compiler complaining about?

        "Love people and use things, not love things and use people." - Unknown

        "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

        V Offline
        V Offline
        VonHagNDaz
        wrote on last edited by
        #3

        Its complaining about the line where I say "class TME_BasicParameters.h" "D:\SvnWork\S168813\Source\TME_Screen_Port\TME_BasicParameters.h", line 2: error: identifier "class" is undefined class TME_BasicParameters ^ "D:\SvnWork\S168813\Source\TME_Screen_Port\TME_BasicParameters.h", line 3: error: expected a ";" { ^ "D:\SvnWork\S168813\Source\TME_Screen_Port\TME_BasicParameters.h", line 174: warning: parsing restarts here after previous syntax error }; Also, I only get the error when I try to include "TME_BasicParameters.h." "TME_BasicParameters" is included in my project. Both files are located in the same directory. Here is the syntax I use in the other file: /* TME_DEFS.h contains all global definitions for the common controller */ #include "TME_BasicParameters.h" /* the number of supported tools */ #define MAXTOOLS 2 /* the number of supported applications */ #define MAXAPPS 255 /* the number of supported stages for a given application */ #define MAXSTAGES 7 /* the number of supported tightening groups */ #define MAXTIGHTGRPS 8 Pretty basic, but maybe that snipet will help shine some light.

        [Insert Witty Sig Here]

        D 1 Reply Last reply
        0
        • V VonHagNDaz

          hey guys, I'm having a problem with a project I'm working on. When I compile my project, I get a "undeclared identifier "class" error. ***no includes(not part of code)*** class TME_BasicParameters { public: * values taken from the basic programming screen */ float torqueHighLim; float turnOffStage2; float torqueLowLim; float startAngle; float turnOffStage1; float trigger; float stage1Speed; float angleLowLim; float turnOffAngle; float angleHighLim; float stage2Speed; float backoff; int strategy; int app; int tool; }; :confused: any ideas?

          S Offline
          S Offline
          Saurabh Garg
          wrote on last edited by
          #4

          This error is typically caused by a missing semi-colon in a class definition. Check the files in included in this source file and see if you missed any semi-color for a class or struct definition. -Saurabh

          1 Reply Last reply
          0
          • V VonHagNDaz

            Its complaining about the line where I say "class TME_BasicParameters.h" "D:\SvnWork\S168813\Source\TME_Screen_Port\TME_BasicParameters.h", line 2: error: identifier "class" is undefined class TME_BasicParameters ^ "D:\SvnWork\S168813\Source\TME_Screen_Port\TME_BasicParameters.h", line 3: error: expected a ";" { ^ "D:\SvnWork\S168813\Source\TME_Screen_Port\TME_BasicParameters.h", line 174: warning: parsing restarts here after previous syntax error }; Also, I only get the error when I try to include "TME_BasicParameters.h." "TME_BasicParameters" is included in my project. Both files are located in the same directory. Here is the syntax I use in the other file: /* TME_DEFS.h contains all global definitions for the common controller */ #include "TME_BasicParameters.h" /* the number of supported tools */ #define MAXTOOLS 2 /* the number of supported applications */ #define MAXAPPS 255 /* the number of supported stages for a given application */ #define MAXSTAGES 7 /* the number of supported tightening groups */ #define MAXTIGHTGRPS 8 Pretty basic, but maybe that snipet will help shine some light.

            [Insert Witty Sig Here]

            D Offline
            D Offline
            David Crow
            wrote on last edited by
            #5

            VonHagNDaz wrote:

            Its complaining about the line where I say "class TME_BasicParameters.h"

            Why the .h at the end of the class name?

            "Love people and use things, not love things and use people." - Unknown

            "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

            V 1 Reply Last reply
            0
            • D David Crow

              VonHagNDaz wrote:

              Its complaining about the line where I say "class TME_BasicParameters.h"

              Why the .h at the end of the class name?

              "Love people and use things, not love things and use people." - Unknown

              "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

              V Offline
              V Offline
              VonHagNDaz
              wrote on last edited by
              #6

              typo :doh: full code: TME_BasicParameters.h class BasicParameters { /* values taken from the basic programming screen */ float torqueHighLim; float turnOffStage2; float torqueLowLim; float startAngle; float turnOffStage1; float trigger; float stage1Speed; float angleLowLim; float turnOffAngle; float angleHighLim; float stage2Speed; float backoff; int strategy; int app; int tool; }; TME_DEFS.h /* TME_DEFS.h contains all global definitions for the common controller */ /* the number of supported tools */ #define MAXTOOLS 2 /* the number of supported applications */ #define MAXAPPS 255 /* the number of supported stages for a given application */ #define MAXSTAGES 7 /* the number of supported tightening groups */ #define MAXTIGHTGRPS 8 #include "TME_BasicParameters.h"

              [Insert Witty Sig Here]

              D 1 Reply Last reply
              0
              • V VonHagNDaz

                typo :doh: full code: TME_BasicParameters.h class BasicParameters { /* values taken from the basic programming screen */ float torqueHighLim; float turnOffStage2; float torqueLowLim; float startAngle; float turnOffStage1; float trigger; float stage1Speed; float angleLowLim; float turnOffAngle; float angleHighLim; float stage2Speed; float backoff; int strategy; int app; int tool; }; TME_DEFS.h /* TME_DEFS.h contains all global definitions for the common controller */ /* the number of supported tools */ #define MAXTOOLS 2 /* the number of supported applications */ #define MAXAPPS 255 /* the number of supported stages for a given application */ #define MAXSTAGES 7 /* the number of supported tightening groups */ #define MAXTIGHTGRPS 8 #include "TME_BasicParameters.h"

                [Insert Witty Sig Here]

                D Offline
                D Offline
                David Crow
                wrote on last edited by
                #7

                I don't see anything wrong with line #2 of the TME_BasicParameters.h file. Are you using .c or .cpp files?

                "Love people and use things, not love things and use people." - Unknown

                "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

                V 1 Reply Last reply
                0
                • D David Crow

                  I don't see anything wrong with line #2 of the TME_BasicParameters.h file. Are you using .c or .cpp files?

                  "Love people and use things, not love things and use people." - Unknown

                  "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

                  V Offline
                  V Offline
                  VonHagNDaz
                  wrote on last edited by
                  #8

                  The majority of the project files are .c, written a long, long time ago. I've been assigned to maintain and add a few new features. My goal was to make the newer features more object oriented as opposed to millions of structs that the old code was using. I could always give up and continue adding to the endless amount of structs, but I wanted to begin adding more object oriented techniques and get away from some of the older c stuff.

                  [Insert Witty Sig Here]

                  D 1 Reply Last reply
                  0
                  • V VonHagNDaz

                    The majority of the project files are .c, written a long, long time ago. I've been assigned to maintain and add a few new features. My goal was to make the newer features more object oriented as opposed to millions of structs that the old code was using. I could always give up and continue adding to the endless amount of structs, but I wanted to begin adding more object oriented techniques and get away from some of the older c stuff.

                    [Insert Witty Sig Here]

                    D Offline
                    D Offline
                    David Crow
                    wrote on last edited by
                    #9

                    VonHagNDaz wrote:

                    The majority of the project files are .c,

                    Which may be why the compiler is complaining about the class keyword.

                    "Love people and use things, not love things and use people." - Unknown

                    "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

                    V 1 Reply Last reply
                    0
                    • D David Crow

                      VonHagNDaz wrote:

                      The majority of the project files are .c,

                      Which may be why the compiler is complaining about the class keyword.

                      "Love people and use things, not love things and use people." - Unknown

                      "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

                      V Offline
                      V Offline
                      VonHagNDaz
                      wrote on last edited by
                      #10

                      Aren't most compilers smart enough to cross compile c and c++ files in the same project, or am I confused?

                      [Insert Witty Sig Here]

                      D CPalliniC 2 Replies Last reply
                      0
                      • V VonHagNDaz

                        Aren't most compilers smart enough to cross compile c and c++ files in the same project, or am I confused?

                        [Insert Witty Sig Here]

                        D Offline
                        D Offline
                        David Crow
                        wrote on last edited by
                        #11

                        There's nothing wrong with having .c and .cpp files in the same project.

                        "Love people and use things, not love things and use people." - Unknown

                        "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

                        1 Reply Last reply
                        0
                        • V VonHagNDaz

                          Aren't most compilers smart enough to cross compile c and c++ files in the same project, or am I confused?

                          [Insert Witty Sig Here]

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

                          I suppose they're smart enough to consider *.c files as C sources, while *.cpp ones as C++ sources. :)

                          If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                          This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke

                          In testa che avete, signor di Ceprano?

                          V 1 Reply Last reply
                          0
                          • CPalliniC CPallini

                            I suppose they're smart enough to consider *.c files as C sources, while *.cpp ones as C++ sources. :)

                            If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                            This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke

                            V Offline
                            V Offline
                            VonHagNDaz
                            wrote on last edited by
                            #13

                            CPallini wrote:

                            I suppose they're smart enough to consider *.c files as C sources, while *.cpp ones as C++ sources.

                            correct, but what I'm trying to do is make a class in a .cpp file. Long story short I gave up and I'm using structs now, but structs cant have member functions, so I'm confused. I've only been exposed to OOP in c++, and I've poked c with a 10 foot pole once. I need member functions for the struct, or is that strictly c++ OOP? Google isn't turning up much when I search for member functions for structs, I'm guessing this is a lost cause as well. dumb programming question #2 : If I was trying to make a more object oriented approach in c, where would I begin? That might be a basic question, but if you've been reading, all my attempts so far have failed, or are wrong... moral : Colleges need more classes on just c and non OOP approaches. In school we had 10+ c++ OOP classes, and one c class where they said "This is c, no one uses it anymore, but now you've been exposed to it..."

                            [Insert Witty Sig Here]

                            CPalliniC 1 Reply Last reply
                            0
                            • V VonHagNDaz

                              CPallini wrote:

                              I suppose they're smart enough to consider *.c files as C sources, while *.cpp ones as C++ sources.

                              correct, but what I'm trying to do is make a class in a .cpp file. Long story short I gave up and I'm using structs now, but structs cant have member functions, so I'm confused. I've only been exposed to OOP in c++, and I've poked c with a 10 foot pole once. I need member functions for the struct, or is that strictly c++ OOP? Google isn't turning up much when I search for member functions for structs, I'm guessing this is a lost cause as well. dumb programming question #2 : If I was trying to make a more object oriented approach in c, where would I begin? That might be a basic question, but if you've been reading, all my attempts so far have failed, or are wrong... moral : Colleges need more classes on just c and non OOP approaches. In school we had 10+ c++ OOP classes, and one c class where they said "This is c, no one uses it anymore, but now you've been exposed to it..."

                              [Insert Witty Sig Here]

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

                              Only C++ structs allow member functions (C++ structs are just classes with different default visibility rules). Maybe I missed a point: if you need OOP, while are you using C language?

                              VonHagNDaz wrote:

                              If I was trying to make a more object oriented approach in c,

                              Use C++. C language is best suited for structured programming. There's nothing wrong in following structured programming paradigm: for small projects it is a winning approach. On the other hand, if you need to exploit OOP advantages, you should use an object oriented language, such C++. :)

                              If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                              This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke

                              In testa che avete, signor di Ceprano?

                              V 1 Reply Last reply
                              0
                              • CPalliniC CPallini

                                Only C++ structs allow member functions (C++ structs are just classes with different default visibility rules). Maybe I missed a point: if you need OOP, while are you using C language?

                                VonHagNDaz wrote:

                                If I was trying to make a more object oriented approach in c,

                                Use C++. C language is best suited for structured programming. There's nothing wrong in following structured programming paradigm: for small projects it is a winning approach. On the other hand, if you need to exploit OOP advantages, you should use an object oriented language, such C++. :)

                                If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                                This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke

                                V Offline
                                V Offline
                                VonHagNDaz
                                wrote on last edited by
                                #15

                                CPallini wrote:

                                while are you using C language?

                                all of the source is in c. This is a massive amount of code I'm maintaining and adding new features to. I thought that I could use .cpp classes, include the .h files in the .c files, and access the object's member functions through pointers. The approach made sense to me, but I guess I'm stuck with c structs and no member functions.

                                [Insert Witty Sig Here]

                                CPalliniC 1 Reply Last reply
                                0
                                • V VonHagNDaz

                                  CPallini wrote:

                                  while are you using C language?

                                  all of the source is in c. This is a massive amount of code I'm maintaining and adding new features to. I thought that I could use .cpp classes, include the .h files in the .c files, and access the object's member functions through pointers. The approach made sense to me, but I guess I'm stuck with c structs and no member functions.

                                  [Insert Witty Sig Here]

                                  CPalliniC Offline
                                  CPalliniC Offline
                                  CPallini
                                  wrote on last edited by
                                  #16

                                  Why don't you upgrade to C++ (i.e. rename from .c to .cpp) the files wherein you want to use classes? :)

                                  If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                                  This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke

                                  In testa che avete, signor di Ceprano?

                                  V 1 Reply Last reply
                                  0
                                  • CPalliniC CPallini

                                    Why don't you upgrade to C++ (i.e. rename from .c to .cpp) the files wherein you want to use classes? :)

                                    If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                                    This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke

                                    V Offline
                                    V Offline
                                    VonHagNDaz
                                    wrote on last edited by
                                    #17

                                    :doh: Why are the simplest answers the hardest to find? [Insert Witty Sig Here]

                                    CPalliniC 1 Reply Last reply
                                    0
                                    • V VonHagNDaz

                                      :doh: Why are the simplest answers the hardest to find? [Insert Witty Sig Here]

                                      CPalliniC Offline
                                      CPalliniC Offline
                                      CPallini
                                      wrote on last edited by
                                      #18

                                      Often posting the right question is difficult. :rolleyes:

                                      If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                                      This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke

                                      In testa che avete, signor di Ceprano?

                                      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