• Advertisement

Archived

This topic is now archived and is closed to further replies.

Errors + Syntax Q's

This topic is 5822 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I''m starting Windows programming in c++ and I have a few questions. I tried to compile some sample code from my book and it''s giving me some erros.
#include <windows.h>

LRESULT CALLBACK fnMessageProcessor (HWND, UINT, WPARAM, LPARMA);

int WINAPI WinMain (HINSTANCE hInstance, HINTANCE hPrevInstance,
					PSTR szCommandLine, int iCommandShow)
{
....
}
I hope HTML works here =-) It gives me an error saying "return type expected" for those two lines. Can anyone help me here? Also, why does the code implement that kind of syntax (like "int WINAPI WinMain"). I''m sure there something here I haven''t learned about. "I''''m not evil... I just use the power of good in evil ways."

Share this post


Link to post
Share on other sites
Advertisement

there are about a billion ways to declare WinMain

int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
return 0;
}


return type expected means it wants to see a return type somewhere.

the APIENTRY or PASCAL or CALLBACK all set how parameters are pushed on the stack.

Share this post


Link to post
Share on other sites
>> return type expected means it wants to see a return type somewhere

Obviously, but aren''t LRESULT and int both the return types it''s asking for?

I also tried your example:

#include <windows.h>
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
return 0;
}

and it''s now giving me an error: "unresolved external ''_main'' referenced from...."

I''ve seen this error a few times and I don''t know what it means.
Why can''t they make this as easy as it is in Java =-(

"I''''m not evil... I just use the power of good in evil ways."

Share this post


Link to post
Share on other sites
May sound a silly question, but have you declared any of your variables you are passing?

Share this post


Link to post
Share on other sites
@Tac-Tics

Have you chosen the right application for your programm?
(i think wou need win32-app not win32-console-app)


The Wild Wild West - Desperado!

Share this post


Link to post
Share on other sites
When you created your project you chose console app, which means your compiler is looking for main(), and since this is a windows app, it''s not finding it, and is complaining appropriately.

Recreate your project/workspace and be careful to chose win32 app, not console. it will compile fine then.

Share this post


Link to post
Share on other sites
In the declaration of fnMessageProcessor you misspelled LPARAM, and in the declaration of WinMain you misspelled HINSTANCE. This probably confuses the parser (though you should have received other errors as well, complaining about the unknown names).

Share this post


Link to post
Share on other sites
Hrmm... I don''t know where that misspelling came in (I really hate the MS abbriviations for everything >=-( I think I tried compiling it correctly spelled at one point. It''s still giving me the _main reference error.

As for WildWest and AbsoluteDew, I thought I wrote this, but I''m using Borland''s C++ compiler and a text editor called Textpad. I at no point got to decide to make it a console app or a window app =-|

"I''''m not evil... I just use the power of good in evil ways."

Share this post


Link to post
Share on other sites

  • Advertisement