Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


We're also offering banner ads on our site from just $5! 1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Errors + Syntax Q's


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
8 replies to this topic

#1 Tac-Tics   Members   -  Reputation: 197

Like
Likes
Like

Posted 09 February 2002 - 01:41 PM

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."

Sponsor:

#2 EvilCrap   Members   -  Reputation: 134

Like
Likes
Like

Posted 09 February 2002 - 05:31 PM


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.

#3 SpaceRook   Members   -  Reputation: 160

Like
Likes
Like

Posted 09 February 2002 - 06:05 PM

quote:
Original post by Tac-Tics
Also, why does the code implement that kind of syntax (like "int WINAPI WinMain").



Welcome to the wonderful world of Windows programming.



-------------
SpaceRook
Latest Project: Paper Shredder
Visit my homepage for other projects!

#4 Tac-Tics   Members   -  Reputation: 197

Like
Likes
Like

Posted 09 February 2002 - 09:11 PM

>> 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."

#5 Unifex   Members   -  Reputation: 122

Like
Likes
Like

Posted 10 February 2002 - 11:02 PM

May sound a silly question, but have you declared any of your variables you are passing?

#6 WildWest   Members   -  Reputation: 184

Like
Likes
Like

Posted 11 February 2002 - 12:58 AM

@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!

#7 AbsolutDew   Members   -  Reputation: 122

Like
Likes
Like

Posted 11 February 2002 - 05:05 AM

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.



#8 Dactylos   Members   -  Reputation: 122

Like
Likes
Like

Posted 11 February 2002 - 05:17 AM

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).

#9 Tac-Tics   Members   -  Reputation: 197

Like
Likes
Like

Posted 11 February 2002 - 10:48 AM

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."




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS