News:

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

Main Menu

Recent posts

#51
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
#52
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
#53
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!   :)  :)  :)
#54
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;
}
#55
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;
}
// ------
#56
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).
#57
Assembly discussions / Syslink demo
Last post by Vortex - June 01, 2025, 12:41:01 PM
Hello,

Here is a syslink control demo :

WndProc PROC hWnd:DWORD,uMsg:DWORD,wParam:DWORD,lParam:DWORD
           
    .IF uMsg==WM_DESTROY

        invoke  PostQuitMessage,NULL

    .ELSEIF uMsg==WM_CREATE

        invoke  CreateWindowEx,0,ADDR SysClass,ADDR text,\
                WS_CHILD or WS_VISIBLE or WS_CLIPSIBLINGS or WS_CLIPCHILDREN,\
                20,20,200,40,hWnd,9999,hInstance,0

        mov     hSyslink,eax
        invoke  GetDlgCtrlID,eax
        mov     SyslinkID,eax

    .ELSEIF uMsg==WM_NOTIFY

        mov eax,SyslinkID
       
            .IF wParam==eax
           
                mov edx,lParam
               
                .IF NMHDR.code[edx]==NM_CLICK || NMHDR.code[edx]==NM_RETURN
                    invoke ShellExecute,0,ADDR verb,ADDR url,NULL,NULL,SW_SHOWNORMAL
                .ENDIF
               
            .ENDIF
#58
Expert questions / Re: Re: Using a structure as r...
Last post by John Z - June 01, 2025, 11:33:12 AM
Thanks pkparchure,

Quote from: pkparchure on June 01, 2025, 08:03:58 AMAs suggested I have extracted main code pertaining to statistical analysis and a complete project is attached as a zip file.

I can't explain it  :( !
Tried various modifications and could not get it to show, just as you have experienced.
Also can't explain why when I drop just that same structure and proc into my existing program it does show.  Stumped for now.

John Z
#59
Expert questions / Re: Re: Using a structure as r...
Last post by TimoVJL - June 01, 2025, 09:27:12 AM
pobr.exe /B /W /Ftest.db3 gsStat.c
pobr.exe /L /Ftest.db3
proves, that function is missing from database.
#60
Expert questions / Re: Using a structure as retur...
Last post by pkparchure - June 01, 2025, 08:03:58 AM
As suggested I have extracted main code pertaining to statistical analysis and a complete project is attached as a zip file. Exe file is also there if it does not get dropped. However, the program can be easily compiled within the project.

I have also put a ReadMe.txt file within the zip file giving some explanations about the program and myself.


TimoVJL, John Z and MrBcx - Thanks a lot for your responses. I wish to tell MrBcx that I am a great fan of BCX - Basic to C translator.