Pelles C forum

C language => Windows questions => Topic started by: Akko on September 20, 2018, 11:24:05 PM

Title: Simple console program
Post by: Akko 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; }
Title: Re: Simple console program
Post by: DMac on September 21, 2018, 12:12:49 AM
Try

Project>Options>Compiler tab>Enable Microsoft extensions
Title: Re: Simple console program
Post by: Akko 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....
Title: Re: Simple console program
Post by: TimoVJL 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>