Thursday, April 1, 2021

Error C2238 unexpected token(s) preceding ';'

Error C2238 unexpected token(s) preceding ';' douglas c:\demo_mfc\dphull_demo\douglas\containers.h 248

When I compiled this project: C:\Demo_MFC\DPHull_demo, I got this error. it can be circular dependency among classes issue.

  1. C++ header error C2238 unexpected token ';'
  2. There is a C2238 error in the PauseMenu header file on the line: Game* game; It says that ';' is an unexpected token, as well as: C2143 syntax error: missing ';' before '*' on the same line; I have no idea what's wrong in those files, I thought both files are correct.

  3. Resolve build errors due to circular dependency amongst classes
  4. I often find myself in a situation where I am facing multiple compilation/linker errors in a C++ project due to some bad design decisions (made by someone else :) ) which lead to circular dependencies between C++ classes in different header files (can happen also in the same file). But fortunately(?) this doesn't happen often enough for me to remember the solution to this problem for the next time it happens again.

    So for the purposes of easy recall in the future I am going to post a representative problem and a solution along with it. Better solutions are of-course welcome.

  5. /showIncludes (List Include Files)
  6. Causes the compiler to output a list of the include files. Nested include files are also displayed (files that are included from the files that you include)..

    To set this compiler option in the Visual Studio development environment Open the project's Property Pages dialog box. For details, see Set C++ compiler and build properties in Visual Studio.

    1. Click the C/C++ folder.
    2. Click the Advanced property page.
    3. Modify the Show Includes property.

  7. This is a paragraph.

  8. This is a paragraph.

  9. This is a paragraph.

  10. This is a paragraph.

  11. This is a paragraph.

  12. This is a paragraph.

  13. This is a paragraph.

  14. This is a paragraph.

  15. This is a paragraph.

  16. This is a paragraph.

  17. This is a paragraph.

  18. This is a paragraph.

  19. This is a paragraph.

  20. This is a paragraph.

  21. This is a paragraph.

No comments:

Post a Comment