Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. Strange error when is include new class. (MSVS 2010)
QtWS25 Last Chance

Strange error when is include new class. (MSVS 2010)

Scheduled Pinned Locked Moved Installation and Deployment
6 Posts 3 Posters 4.2k Views
  • 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.
  • G Offline
    G Offline
    Grybb
    wrote on last edited by
    #1

    When I add a header file of my class then is happen this error:

    @1>d:\qt\4.8.0\include\qtcore../../src/corelib/kernel/qeventloop.h(95): error C2143: syntax error : missing ')' before 'constant'
    1>d:\qt\4.8.0\include\qtcore../../src/corelib/kernel/qeventloop.h(95): error C2143: syntax error : missing ';' before 'constant'
    1>d:\qt\4.8.0\include\qtcore../../src/corelib/kernel/qeventloop.h(95): error C2805: binary 'operator |' has too few parameters
    1>d:\qt\4.8.0\include\qtcore../../src/corelib/kernel/qeventloop.h(95): error C2059: syntax error : ')'
    1>d:\qt\4.8.0\include\qtcore../../src/corelib/kernel/qeventloop.h(95): error C2143: syntax error : missing ';' before '{'
    1>d:\qt\4.8.0\include\qtcore../../src/corelib/kernel/qeventloop.h(95): error C2447: '{' : missing function header (old-style formal list?)
    1>d:\qt\4.8.0\include\qtcore../../src/corelib/kernel/qeventloop.h(95): error C2143: syntax error : missing ')' before 'constant'
    1>d:\qt\4.8.0\include\qtcore../../src/corelib/kernel/qeventloop.h(95): error C2143: syntax error : missing ';' before 'constant'
    1>d:\qt\4.8.0\include\qtcore../../src/corelib/kernel/qeventloop.h(95): error C2059: syntax error : ')'
    1>d:\qt\4.8.0\include\qtcore../../src/corelib/kernel/qeventloop.h(95): error C2059: syntax error : '}'
    1>d:\qt\4.8.0\include\qtcore../../src/corelib/kernel/qeventloop.h(95): error C2059: syntax error : '}'@

    When I into my primary Main Window class add this
    @#include "mynewclass.h"@

    If I comment this piece of code:
    @//#include "mynewclass.h"@

    Everything works fine.

    Class is usual C++ class (no QT) and in my test project works fine, so in class shouldn´t be error. I don´t understand this error and link between add new class and qeventloop…

    1 Reply Last reply
    0
    • K Offline
      K Offline
      koahnig
      wrote on last edited by
      #2

      Based on this information it is hard to give a sound advice.
      My assumption is that there is a define in your new header which is messing up a bit things.

      Are you including the new header at the very top respectively before includes of Qt headers?

      Vote the answer(s) that helped you to solve your issue(s)

      1 Reply Last reply
      0
      • G Offline
        G Offline
        Grybb
        wrote on last edited by
        #3

        Should I include header of my classes before include of QT header?

        Anyway you answer helped me – thank you. The mistake was in defined of constants. In my class I have lots of constants (like this: #define xy 1234) and it´s caused the error. Now I´m (thank to you) a little bit smarter. How you wrote probably some constant was define twice…

        1 Reply Last reply
        0
        • K Offline
          K Offline
          koahnig
          wrote on last edited by
          #4

          You are welcome.

          Personally I would place the Qt headers first. But this may vary with the actual implementation. The defines are typically causing such problems. You should review your code carefully.

          Vote the answer(s) that helped you to solve your issue(s)

          1 Reply Last reply
          0
          • G Offline
            G Offline
            goetz
            wrote on last edited by
            #5

            If possible, you could change to true constants, instead of preprocessor macros.

            If you need to stick to macros, it's always a good idea to start the macro names with some prefix common to you project, so for example instead of just using NUMFILES, it would be better to use QTC_NUMFILES (if we assume coding for Qt Creator here). This way you have much better chances that it doesn't clash with some other #defines.

            http://www.catb.org/~esr/faqs/smart-questions.html

            1 Reply Last reply
            0
            • G Offline
              G Offline
              Grybb
              wrote on last edited by
              #6

              You´re right, real constants are maybe better idea. For now I added prefix.

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved