Author Topic: Simple console program  (Read 1341 times)

Offline Akko

  • Member
  • *
  • Posts: 21
Simple console program
« on: September 20, 2018, 11:24:05 pm »
Why won't the simple console program below compile with Pelles C?
It compiles and runs flawless with gcc and clang.

With Pelles C I get either "No target architecture" or "unresolved WinMain".
Anyhow it is a console program, so I shouldn't need WinMain at all IMHO.

// --- Set console cursor to {10,10}
#include <stdio.h>
#define _CONSOLE
#include <windows.h>

void atxy(int x, int y) {
  HANDLE hStdout;
  COORD coord;
  hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
  coord.Y = y, coord.X = x;
  SetConsoleCursorPosition(hStdout,coord); }

int main (void) {
  return 0; }

Offline DMac

  • Member
  • *
  • Posts: 258
Re: Simple console program
« Reply #1 on: September 21, 2018, 12:12:49 am »

Project>Options>Compiler tab>Enable Microsoft extensions
No one cares how much you know,
until they know how much you care.

Offline Akko

  • Member
  • *
  • Posts: 21
Re: Simple console program
« Reply #2 on: September 21, 2018, 04:43:27 am »
That did it.  Thank you   :)

I am wondering why this /Ze option is there at all.
Pelles C runs on Windows only anyhow AFAIK.
It should not blow up the exe... but perhaps it affects compilation time....

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 1895
Re: Simple console program
« Reply #3 on: September 21, 2018, 11:16:51 am »
PellesC is a C99/C17 compiler.

-Ze option is there as Microsoft Extensions for Windows programs and needed for Windows specific headers.
An additions like:
 __stdcall calling convention.
 __declspec( dllimport ) __declspec( dllexport ) for dlls.
In help-file is a long list of those additions.

For faster compiling define WIN32_LEAN_AND_MEAN before windows.h or in compiler option (-D) define symbols in a project file.
Code: [Select]
#include <windows.h>
May the source be with you