Hello, I'm a new programmer and wanted to create a simple windows application. I might be getting in a little over my head when writing the code below. All seems well when compiling the code without implementing classes. When I implemented the class AppEngine from a separate source file I had these errors that I could not resolve. I came to two conclusions of what I was doing wrong and was hoping that someone could point me in the right direction.

Conclusion 1 - I incorrectly included the source files during compile
Conclusion 2 - I was in over my head and should not attempt windows programming just yet.

The errors I'm receiving are:
Line 12 : new types may not be defined in a return type
Line 4 : requires init-declaration before LRESULT WindowProcedure

I use DEV C++ IDE and these the codes that gets the error.

1 #include <windows.h>
2 #include "DCPPPClasses.h"
3
4 LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT 5 message, WPARAM wParam, LPARAM lParam);
6
7 AppEngine *_pAE;
8
9 _pAE = new AppEngine(HINSTANCE, LPSTR, LPSTR, WORD, 10 WORD, int, int);
11
12 int WINAPI WinMain(HINSTANCE hinstance, HINSTANCE hprevi, 13 LPSTR szcmdline, int icmdshow)
14 {
15 }

I would like to know what those error means and how to fix them. Thanks in advance. Sadaka

If poking it with a stick doesn't work for you. Try poking it with a bigger one.

Recommended Answers

All 7 Replies

how bout using a better api? qt or gtk are much easier.

commented: answer the question. There is nothing wrong with the WinAPI. -2

line 4: LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT 5 message, WPARAM wParam, LPARAM lParam);
line 9: _pAE = new AppEngine(HINSTANCE, LPSTR, LPSTR, WORD, 10 WORD, int, int);

these are the errors. the compiler/ide you are using seems to emit very poor error messages.

also line 12: int WINAPI WinMain(HINSTANCE hinstance, HINSTANCE hprevi, 13 LPSTR szcmdline, int icmdshow)

That's what you get when you copy-paste code... De lines got messed up, and now the linenumbers are in your code:
In line 4: Remove '5'
In line 9: Remove '10'
In line 12: Remove '13'

I added the numbers to indicated the line. I thought it would help indicate which line generated the errors. I figured that I included the external source files incorrectly and that the complier didn't recognize any of my class calls hence error : new types may not be define in a return type. I want to know what that error means because I tried everything I could think of to resolve it but in vain. Next time I'll just attach my source files so there won't be any confusions. Sorry. Thanks again in advance.

Things aren't always what it seems my young grasshopper...

check the header DCPPPClasses.h for a missing ; at the end of the class, mismatched (), {} etc.
line 9: _pAE = new AppEngine(HINSTANCE, LPSTR, LPSTR, WORD, 10 WORD, int, int); is an obvious error on many counts.

oh yes duh... i'm such a dueche bag that's what I left out after the class. Thanks alot bro. i've attached my source if you want to look them over. Thanks again. I've also made changes to the class and added the colon (;). Think that I can attach stuff?

A good deed will not go unnoticed. -Sun Tsu

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.