NO

Author Topic: Simple console program  (Read 2504 times)

Offline Akko

  • Member
  • *
  • Posts: 31
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) {
  atxy(10,10);
  return 0; }

Offline DMac

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

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: 31
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: 2091
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]
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
May the source be with you