Click here to Skip to main content
15,892,927 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
while i am creating a custom dialog in MFC single view application, just for experimentation i was trying to include my view class in mydialog class, which flags error.

VB
// MyDialog.cpp : implementation file
//

#include "stdafx.h"
#include "MFCOne.h"
#include "MyDialog.h"
#include "afxdialogex.h"

// this is the include statement that caused error ...
#include "MFCOneView.h"

// CMyDialog dialog



Error :

error C2143: syntax error : missing ';' before '*'
Posted

1 solution

You might have an actual syntax error, a header dependency problem, or something else. My personal rules for header includes are:

- If precompiled headers are used, the first #include in a .cpp file should be "stdafx.h" (or equiv). This include should never be in a .h file.
- Immediately following the PCH header #include should be the header corresponding to the current file. This will force you to include any system headers in the .h file that are required by that .h file (and will fix many problems with include ordering).
- Following this #include, add any other of your project files needed by the .cpp file to compile correctly (in any order you want; I usually do it alphabetically).
- Following these #includes, add any system headers (ie. that ship with the compiler) that are needed by the .cpp file to compile correctly again, in any order that you want. Note that there are some system headers that have ordering trouble, notably with stl and the min()/max() macros.

Using these rules, the result above would be:

C++
// MyDialog.cpp : implementation file
//

#include "stdafx.h"

#include "MyDialog.h"

#include "MFCOne.h"
#include "MFCOneView.h"

#include "afxdialogex.h"

// CMyDialog dialog


Doing this should either fix your problem or do a better job showing you where the problem lies...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900