NO

Author Topic: First program, First Project and first failure  (Read 2846 times)

BLT

  • Guest
First program, First Project and first failure
« on: December 15, 2012, 06:55:12 PM »
First day, First Program, First Project and first failure...
My source code...got it off the internet.  I suspect the problem is in the way I have set up my project. 
#include <stdio.h>
 
int main(void)
{
    printf("hello, world\n");
}
From Build:

Building HelloMain.obj.
C:\Users\Byron\Documents\Pelles C Projects\Hello\HelloMain.c(4): warning #2203: Function 'main' can't be __stdcall, changed to __cdecl.
Building Hello.exe.
POLINK: error: Unresolved external symbol '_WinMain@16'.
POLINK: fatal error: 1 unresolved external(s).
*** Error code: 1 ***
Done.
Where have I gone wrong? 
Thanks,
BLT


CommonTater

  • Guest
Re: First program, First Project and first failure
« Reply #1 on: December 15, 2012, 07:48:39 PM »
Well... At least you've got the firsts out of the way...
 
There's a couple of things... 
1) Next time create a new project as a *win32 console program* ...  (File -> New -> Project)
 
If you look in the AddIns section you will find an addin called Workspace Manager I wrote to make project creation a lot simpler.... Read the AddIns FAQ for instructions on how to install addins. In the manager the defaults are set so that you won't get these problems (of course more advanced users can still change them)

2) Write your program like this...
Code: [Select]
#include <stdio.h>
 
int _cdecl main (void)
  {
    puts("Hello World!\n\n");
 
    return 0;
  }

There were two problems in your internet code...
A) The calling convention is not specified
B) The operating system expects a returned value that wasn't there.
 
 
3) Open the Pelles C help file; Menu -> Help -> Contents then click your way into...
Contents -> Integrated Environment -> POIDE Integrated Environment -> My first project
and give that a read.

But mostly, you should read.... THIS  ... you're not going to learn programming by taking code snippets off the internet and randomly trying them out.  All that does is frustrate.
 
Welcome to the forums...
 
« Last Edit: December 15, 2012, 08:11:33 PM by CommonTater »

BLT

  • Guest
Re: First program, First Project and first failure
« Reply #2 on: December 16, 2012, 06:19:22 AM »
Thank you for taking the time to save my first project.  Your suggestions worked and I am off an runing (slowly).  BLT

CommonTater

  • Guest
Re: First program, First Project and first failure
« Reply #3 on: December 16, 2012, 10:09:05 PM »
No worries ... I still remember my disasters when just starting out.  (and a few more recent ones too :D )