News:

Download Pelles C here: http://www.smorgasbordet.com/pellesc/

Main Menu

Recent posts

#61
Work in progress / Re: win32-doc md files
Last post by John Z - June 02, 2025, 04:21:40 PM
Here is the newest mdfiles program and MD_Files_3.db3 to use with it.

This version outputs the win32-doc.zip path for every API NAME outputted when using TimoVJL's extract utility.  Note that due to GitHub documentation inconsistencies some API NAMES are not really API NAMES, but these are still handled in this db3.  For example entering /-o shows a list to pick for example /-out yielding a filename and path as
Win32-docs\desktop-src\Midl\-out.md 

This program just shows how to get the filename and path from the db3.  It does not extract the .md file to be displayed in a suitable .md file viewer or using webview.

The .db3 is compressed with zip inside of the project zip and needs to be uncompressed before using.  The db3 file of course can be used by anyone, for anything . . . . as can this program.

John Z
#62
Expert questions / Re: Struggling with function p...
Last post by Pelle - June 02, 2025, 09:29:39 AM
Quote from: Akko on June 01, 2025, 09:34:04 PMGosh, I must have been blinded by our recent thunderstorm...
... but of course ... the famous thunderstorm excuse...  ;D
#63
Expert questions / Re: Using a structure as retur...
Last post by Pelle - June 02, 2025, 09:26:26 AM
Just to be clear: redeclaring a typedef in C99 mode, and not using Microsoft mode (/Ze), will fail.
But this is not relevant in this case...
#64
Expert questions / Re: Re: Using a structure as r...
Last post by pkparchure - June 02, 2025, 08:06:12 AM
As suggested by TimoVJL, I put typedef Statistics Statistics; in file gsStat.c as given below:

typedef Statistics Statistics;

// Function to calculate all statistics
Statistics calculate_statistics(DataStruct gsData, int nRows, int vCol)
{

And it works, the functions {} calculate_statistics is now visible in the panel. Also, the program compiles and runs very well.

It also works if I put: typedef Statistics Statistics; in header file gs.h

Once again, thank you very much Pelle, John Z, TimoVJL, and Mr BCX for the help and guidance.





#65
Expert questions / Re: Re: Using a structure as r...
Last post by John Z - June 01, 2025, 10:19:11 PM
Good explanation Pelle.

Also explains why it always worked for me - everything in the same file for my tests ...

John Z
#66
Expert questions / Re: Using a structure as retur...
Last post by TimoVJL - June 01, 2025, 10:03:38 PM
So, after addingtypedef Statistics Statistics;to gsStat.c, project panel shows {} calculate_statistics
#67
Expert questions / Re: Struggling with function p...
Last post by Akko - June 01, 2025, 09:34:04 PM
Gosh, I must have been blinded by our recent thunderstorm...
Thank you!   :)  :)  :)
#68
Expert questions / Re: Struggling with function p...
Last post by Pelle - June 01, 2025, 08:34:24 PM
OK, the quick & dirty version (with minimum changes):

#include <stdlib.h>

int pop(void) { return rand()&3; }
int tos=0x123456;

typedef int (*PZ)();
typedef int (*PN)(int, ...);

PZ pz;
PN pn;

void runproc(void) { // RUNPROC ( .. fa n -- ret )
   int p1, p2;
   switch (pop()) {
   case 0:   pz=(PZ)tos;
      tos=pz();
      break;
   case 1:   pn=(PN)pop(), p1=tos;
      tos=pn(p1);
      break;
   case 2:   pn=(PN)pop(), p2=pop(), p1=tos;
      tos=pn(p1,p2);
      break;
   default: tos=-21; }
}

int main(void) {
   runproc();
   return tos;
}
#69
Expert questions / Struggling with function point...
Last post by Akko - June 01, 2025, 07:54:21 PM
Hi,
I'm not sure if I'm struggling with my limited knowledge of function pointer syntax or with Pelles C.

The code snippet below (don't ask what it does) compiles flawlessly with gcc, but not with Pelles C V13
(32 bit console mode).

With Pelles C I get the following errors
E:\Develop\M3\fp.c(12): error #2168: Operands of '=' have incompatible types: 'int (*)()' and 'void *'.
E:\Develop\M3\fp.c(15): error #2168: Operands of '=' have incompatible types: 'int (*)(int, ...)' and 'void *'.
E:\Develop\M3\fp.c(18): error #2168: Operands of '=' have incompatible types: 'int (*)(int, ...)' and 'void *'.

I tried many things, including typedefs, without success. But I can't make it work.

Many thanks for your help!!

// ------
#include <stdlib.h>

int pop(void) { return rand()&3; }
int tos=0x123456;

int (*pz)();
int (*pn)(int,...);

void runproc(void) { // RUNPROC ( .. fa n -- ret )
   int p1, p2;
   switch (pop()) {
   case 0:   pz=(void*)tos;
      tos=pz();
      break;
   case 1:   pn=(void*)pop(), p1=tos;
      tos=pn(p1);
      break;
   case 2:   pn=(void*)pop(), p2=pop(), p1=tos;
      tos=pn(p1,p2);
      break;
   default: tos=-21; }
}

int main(void) {
   runproc();
   return tos;
}
// ------
#70
Expert questions / Re: Using a structure as retur...
Last post by Pelle - June 01, 2025, 03:55:29 PM
Parsing the C language is hard. There is some agreement it's one of the harder ones.
( Without more context: does "X * Y" means variable X times variable Y, or is Y a pointer to typedef X? And so on. )

rypedef names are one complication. There are "forks" in the syntax where the parser must know if a name is a type or a variable, to correctly parse the code that follows.

The Pelles C tool that collects information about types are variables is POBR.DLL (with a command-line interface in POBR.EXE). Since POBR.DLL is also used by the IDE, it needs to "work" in interactive mode and on a project that is probably unfinished. Because of this it's generally no time (nor point) to scan every #include file (of every #include file). There may be time to search the symbol database for any recorded typedef names, but doing this repeatedly on an older/slower computer may not br a huge success either.

All that said, what you have is a typedef name in one file (gs.h) used in another file (gsStat.c) and the problem is connecting the two pieces. The current version of POBR.DLL can't hande this well. For now there are only a few options:
1) add a tag to the "Statistics" struct so you can replace the return type "Statistics" with struct <tagname>,
2) make use of one of the heuristics in POBR.DLL to identify a typedef name: <lowercase>_t (generic) or <UPPERCASE> (windows mode), and rename your structs accordingly, or
3) wait for the future, where a new version of POBR.DLL *may* appear that *may* fix this (or not - I can't really see into the future).