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. error C2143

error C2143

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorialquestion
15 Posts 6 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.
  • CPalliniC CPallini

    You might try to get rid of those ugly macros (you are using C++, right?).

    _ Offline
    _ Offline
    _Flaviu
    wrote on last edited by
    #6

    Yes, but I don't know if I can, because from step TestAndClearDirty(ni); to test_and_clear(ni, Name), the second paramter is missing (see the first post). Moreover, at step test_and_clear_bit(NI_##flag, (ni)->state) what is the first parameter ?

    L 1 Reply Last reply
    0
    • _ _Flaviu

      Yes, but I don't know if I can, because from step TestAndClearDirty(ni); to test_and_clear(ni, Name), the second paramter is missing (see the first post). Moreover, at step test_and_clear_bit(NI_##flag, (ni)->state) what is the first parameter ?

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

      That is exactly the problem. We do not have that information and you are not providing it.

      _ 1 Reply Last reply
      0
      • L Lost User

        That is exactly the problem. We do not have that information and you are not providing it.

        _ Offline
        _ Offline
        _Flaviu
        wrote on last edited by
        #8

        Believe me, I haven't extra information, for instance, at step test_and_clear(ni, Name), when I try to go to definition of Name, VS editor goes nowhere, searched globally in the whole project, found nothing, and searched in the entire project folder with the external file seeker, found no defintion of this Name parameter ...

        L 1 Reply Last reply
        0
        • _ _Flaviu

          Believe me, I haven't extra information, for instance, at step test_and_clear(ni, Name), when I try to go to definition of Name, VS editor goes nowhere, searched globally in the whole project, found nothing, and searched in the entire project folder with the external file seeker, found no defintion of this Name parameter ...

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

          In the following macro Name refers to something outside of the definition:

          #define TestAndClearDirty(ni) \
          test_and_clear(ni, Name)

          But if Name does not exist in that source module, or is not externalised in a linked module it will never work. My suspicion is that this macro is wrong and Name should be one of the formal parameters, and refer to one of the flags in the ni struct. Something like:

          #define TestAndClearDirty(ni, Name) \
          test_and_clear(ni, Name)

          And it would be called by

          TestAndClearDirty(ni, some_falg_name);

          But I am working completely in the dark and making (probably wild) guesses. I can only suggest that you go back to the place or person that this code comes from for assistance.

          _ 1 Reply Last reply
          0
          • L Lost User

            In the following macro Name refers to something outside of the definition:

            #define TestAndClearDirty(ni) \
            test_and_clear(ni, Name)

            But if Name does not exist in that source module, or is not externalised in a linked module it will never work. My suspicion is that this macro is wrong and Name should be one of the formal parameters, and refer to one of the flags in the ni struct. Something like:

            #define TestAndClearDirty(ni, Name) \
            test_and_clear(ni, Name)

            And it would be called by

            TestAndClearDirty(ni, some_falg_name);

            But I am working completely in the dark and making (probably wild) guesses. I can only suggest that you go back to the place or person that this code comes from for assistance.

            _ Offline
            _ Offline
            _Flaviu
            wrote on last edited by
            #10

            I have discovered something: if I write:

            TestAndClearDirty(ni);

            everything is ok. But if I write:

            BOOL b = TestAndClearDirty(ni); // <-- errors

            I get errors:

            error C2552: 'b' : non-aggregates cannot be initialized with initializer list
            error C2143: syntax error : missing '}' before 'const'
            error C2143: syntax error : missing ';' before 'const'
            error C2143: syntax error : missing ';' before 'const'
            error C2065: 'old_state' : undeclared identifier

            See first post for original definition ... I hope I can make it ... P.S. Why I written BOOL b = ... ? Because that function, TestAndClearDirty, is used inside some if condition ...

            L L 2 Replies Last reply
            0
            • _ _Flaviu

              I come back for another strange error (for me is strange :) ):

              error C2143: syntax error : missing ')' before '{'

              And the lin with error is:

              TestAndClearDirty(ni); // <-- error C2143: syntax error : missing ')' before '{'

              and TestAndClearDirty is declared as:

              #define TestAndClearDirty(ni) \
              test_and_clear(ni, Name)

              where test_and_clear(ni, Name) is defined as:

              #define test_and_clear(ni, flag) \
              test_and_clear_bit(NI_##flag, (ni)->state)

              and clear_bit is declared as:

              #define test_and_clear_bit(bit, var) \
              ({ \
              const BOOL old_state = test_bit(bit, var); \
              clear_bit(bit, var); \
              old_state; \
              })

              How to get rid of this error ?

              D Offline
              D Offline
              Daniel Pfeffer
              wrote on last edited by
              #11

              When you have so many nested macros, one thing to do is look at a pre-processed version of the code. In MSVC, adding /P to the command line will create a file with a .i extension, containing the pre-processed code. Examining that will probably give you the cause of the error. EDIT: I see someone beat me to giving the same advice.

              Freedom is the freedom to say that two plus two make four. If that is granted, all else follows. -- 6079 Smith W.

              _ 2 Replies Last reply
              0
              • _ _Flaviu

                I have discovered something: if I write:

                TestAndClearDirty(ni);

                everything is ok. But if I write:

                BOOL b = TestAndClearDirty(ni); // <-- errors

                I get errors:

                error C2552: 'b' : non-aggregates cannot be initialized with initializer list
                error C2143: syntax error : missing '}' before 'const'
                error C2143: syntax error : missing ';' before 'const'
                error C2143: syntax error : missing ';' before 'const'
                error C2065: 'old_state' : undeclared identifier

                See first post for original definition ... I hope I can make it ... P.S. Why I written BOOL b = ... ? Because that function, TestAndClearDirty, is used inside some if condition ...

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

                Once again there is considerable context missing. And it seems you have also removed all the macro definitions from your earlier post.

                1 Reply Last reply
                0
                • D Daniel Pfeffer

                  When you have so many nested macros, one thing to do is look at a pre-processed version of the code. In MSVC, adding /P to the command line will create a file with a .i extension, containing the pre-processed code. Examining that will probably give you the cause of the error. EDIT: I see someone beat me to giving the same advice.

                  Freedom is the freedom to say that two plus two make four. If that is granted, all else follows. -- 6079 Smith W.

                  _ Offline
                  _ Offline
                  _Flaviu
                  wrote on last edited by
                  #13

                  I have put that option on property page settings and show me no more details: The error occur in some inode.cpp file (ex C file), and those macros are some support.h file. So, when I compiled with /P option, I got only inode.i file, where I have a line:

                  #line 1 "d:\\project\\.......\\inode.cpp"

                  that is all. And support.i doesn't generated, due to error:

                  fatal error C1083: Cannot open include file: 'stdafx.h': No such file or directory
                  ...
                  fatal error C1083: Cannot open include file: 'stdafx.h': No such file or directory
                  ...
                  fatal error C1083: Cannot open include file: 'stdafx.h': No such file or directory
                  ...

                  The problem is that macro TestAndClearDirty(ni); is

                  1 Reply Last reply
                  0
                  • D Daniel Pfeffer

                    When you have so many nested macros, one thing to do is look at a pre-processed version of the code. In MSVC, adding /P to the command line will create a file with a .i extension, containing the pre-processed code. Examining that will probably give you the cause of the error. EDIT: I see someone beat me to giving the same advice.

                    Freedom is the freedom to say that two plus two make four. If that is granted, all else follows. -- 6079 Smith W.

                    _ Offline
                    _ Offline
                    _Flaviu
                    wrote on last edited by
                    #14

                    I have put that option on property page settings and show me no more details: The error occur in inode.cpp file (former inode.c file), and those macros are in **support.**h file. So, when I compiled with /P option, I got only inode.i file, where I have a line:

                    #line 1 "d:\\project\\.......\\inode.cpp"

                    that is all. And support.i doesn't generated, due to error:

                    fatal error C1083: Cannot open include file: 'stdafx.h': No such file or directory
                    ...
                    fatal error C1083: Cannot open include file: 'stdafx.h': No such file or directory
                    ...
                    fatal error C1083: Cannot open include file: 'stdafx.h': No such file or directory
                    ...

                    The problem is the code is trying to use TestAndClearDirty(ni); for returning BOOL value, and I don't think that macro is written to return a BOOL value ... I guess from here is coming these errors ...

                    1 Reply Last reply
                    0
                    • _ _Flaviu

                      I have discovered something: if I write:

                      TestAndClearDirty(ni);

                      everything is ok. But if I write:

                      BOOL b = TestAndClearDirty(ni); // <-- errors

                      I get errors:

                      error C2552: 'b' : non-aggregates cannot be initialized with initializer list
                      error C2143: syntax error : missing '}' before 'const'
                      error C2143: syntax error : missing ';' before 'const'
                      error C2143: syntax error : missing ';' before 'const'
                      error C2065: 'old_state' : undeclared identifier

                      See first post for original definition ... I hope I can make it ... P.S. Why I written BOOL b = ... ? Because that function, TestAndClearDirty, is used inside some if condition ...

                      L Offline
                      L Offline
                      leon de boer
                      wrote on last edited by
                      #15

                      test_and_clear is a macro you can't use it as a function, macros don't return things without hijinx :-) GCC has a thing called a statement expression Using the GNU Compiler Collection (GCC): Statement Exprs[^] However I strong suggestly you don't do it just create a proper function (that is after all what you are trying to write) and inline it if speed is an issue.

                      In vino veritas

                      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