Author Topic: Compiling a PM sample with GCC (2023)  (Read 95656 times)

Martin Iturbide

  • OS2World NewsMaster
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4748
  • Karma: +41/-1
  • Your Friend Wil Declares...
    • View Profile
    • Martin's Personal Blog
Re: Compiling a PM sample with GCC (2023)
« Reply #45 on: April 30, 2023, 02:23:50 am »
Thanks Dave, Rich

The warnings are now gone, and I think I'm done with this sample.

I had choose to use wipfc (watcom-wipfc package) on this case and the INF file is also included on the makefile. It worked fine as far as I can notice.

I uploaded the files to:
https://github.com/OS2World/DEV-SAMPLES-PM-Air_Traffic_Control_Container

Thanks
Martin Iturbide
OS2World NewsMaster
... just share the dream.

Martin Iturbide

  • OS2World NewsMaster
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4748
  • Karma: +41/-1
  • Your Friend Wil Declares...
    • View Profile
    • Martin's Personal Blog
Re: Compiling a PM sample with GCC (2023)
« Reply #46 on: April 30, 2023, 03:20:31 am »
Hello again.

Now I want to try this one:
https://github.com/OS2World/DEV-SAMPLES-PM-AVBrowse

It is a OS/2 File Browser sample, but this one has a dependency on opendlg.h, so I grabbed it from a another sample, but I'm not sure if I'm doing it right. Should I try to find OPENDLG.LIB? not sure where to find it.

Update: I found an old discussion about OpenDLG, but not sure if we solve it.

I have this errors that I don't know how to solve:

Code: [Select]
gcc -Wall -Zomf -c -O2 browse.c -o browse.obj
In file included from browse.c:15:
browse.h:18:22: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'RetrieveLine'
   18 | const char * _loadds RetrieveLine(USHORT);
      |                      ^~~~~~~~~~~~
browse.c: In function 'main':
browse.c:83:30: error: 'RetrieveLine' undeclared (first use in this function)
   83 |      lbiData.pfnQL = (PFNQL) RetrieveLine;
      |                              ^~~~~~~~~~~~
browse.c:83:30: note: each undeclared identifier is reported only once for each function it appears in
browse.c: At top level:
browse.c:191:16: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'RetrieveLine'
  191 | char * _loadds RetrieveLine(USHORT usLineNum) {
      |                ^~~~~~~~~~~~
make: *** [browse.obj] Error 1

Regards
« Last Edit: April 30, 2023, 03:34:48 am by Martin Iturbide »
Martin Iturbide
OS2World NewsMaster
... just share the dream.

Dave Yeo

  • Hero Member
  • *****
  • Posts: 4805
  • Karma: +99/-1
    • View Profile
Re: Compiling a PM sample with GCC (2023)
« Reply #47 on: April 30, 2023, 04:54:12 am »
There's something missing, likely an include, possibly a different opendlg.h. There should also be a (sibling?) VBROWSE directory according to the readme, and it seems old enough to use the msc compiler.
If no one else has any ideas, might be best to move on.

Martin Iturbide

  • OS2World NewsMaster
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4748
  • Karma: +41/-1
  • Your Friend Wil Declares...
    • View Profile
    • Martin's Personal Blog
Re: Compiling a PM sample with GCC (2023)
« Reply #48 on: April 30, 2023, 02:16:19 pm »
Hi

I also remove the warnings and compile with gcc the Slider2 sample (not to confuse with Slider).
https://github.com/OS2World/DEV-SAMPLES-PM-Slider_2

Only the Horizontal Slider works, the vertical one was not implemented.
It does not look like good, even the older executable, but I think it may be some work in progress.

Regards
Martin Iturbide
OS2World NewsMaster
... just share the dream.

Martin Iturbide

  • OS2World NewsMaster
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4748
  • Karma: +41/-1
  • Your Friend Wil Declares...
    • View Profile
    • Martin's Personal Blog
Re: Compiling a PM sample with GCC (2023)
« Reply #49 on: April 30, 2023, 06:05:06 pm »
Hi

And ZoomBMP was also an easy fix to compile with gcc 9. All warnings were removed.

- https://github.com/OS2World/DEV-SAMPLES-C-PM-ZoomBMP

The only thing that I see is that it seems to be some display error on the program when it loads the image for the first time, then the zoom out and zoom in with the mouse buttons works fine.

Regards

Martin Iturbide
OS2World NewsMaster
... just share the dream.

Martin Iturbide

  • OS2World NewsMaster
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4748
  • Karma: +41/-1
  • Your Friend Wil Declares...
    • View Profile
    • Martin's Personal Blog
Re: Compiling a PM sample with GCC (2023)
« Reply #50 on: April 30, 2023, 06:13:22 pm »
Hi Again

I have an issue with this one. It is supposed to be a very simple and short sample of a PM Window (I guess), it compiles, no warning, no errors, but the exe produce an error on popuplog.

https://github.com/OS2World/DEV-SAMPLES-C-PM-WindowTemplate

Any help is welcome.

Thanks
Martin Iturbide
OS2World NewsMaster
... just share the dream.

Dave Yeo

  • Hero Member
  • *****
  • Posts: 4805
  • Karma: +99/-1
    • View Profile
Re: Compiling a PM sample with GCC (2023)
« Reply #51 on: April 30, 2023, 06:58:51 pm »
Too small of a stack, increasing it to 8192 in the def file fixes the crash. Works with a smaller heap too.
There must be a way to calculate the needed sizes but have no idea how besides trial and error.
DLG.DEF
Code: [Select]
NAME      dlg WINDOWAPI
DESCRIPTION  'dlg - Data Window and Control Uitility'

STACKSIZE    8192
HEAPSIZE     1024

Martin Iturbide

  • OS2World NewsMaster
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4748
  • Karma: +41/-1
  • Your Friend Wil Declares...
    • View Profile
    • Martin's Personal Blog
Re: Compiling a PM sample with GCC (2023)
« Reply #52 on: April 30, 2023, 07:29:44 pm »
Thanks Dave, it worked.

Just one question, do you know where do you set the window size on the PM? The program runs small and you have to rezise the window to see it.
Do you know where can I change that?

Regards
Martin Iturbide
OS2World NewsMaster
... just share the dream.

Dave Yeo

  • Hero Member
  • *****
  • Posts: 4805
  • Karma: +99/-1
    • View Profile
Re: Compiling a PM sample with GCC (2023)
« Reply #53 on: April 30, 2023, 08:07:17 pm »
Seems to be a resource as DLG.C has no WinCreateWindow() function. Perhaps it could be added?
Hopefully someone else understands how to.

Alex Taylor

  • Sr. Member
  • ****
  • Posts: 389
  • Karma: +5/-0
    • View Profile
Re: Compiling a PM sample with GCC (2023)
« Reply #54 on: April 30, 2023, 08:39:30 pm »
Just one question, do you know where do you set the window size on the PM? The program runs small and you have to rezise the window to see it.
Do you know where can I change that?

Looks like the WinSetWindowPos() on line 61 of DLG.C is setting the window size to 150,150 (fifth & sixth arguments). Increase those numbers if you want a bigger window.

Martin Iturbide

  • OS2World NewsMaster
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4748
  • Karma: +41/-1
  • Your Friend Wil Declares...
    • View Profile
    • Martin's Personal Blog
Re: Compiling a PM sample with GCC (2023)
« Reply #55 on: April 30, 2023, 09:35:29 pm »
Hi Rich

Martin, I know you think you are being "helpful" ...
"You know?": Wrong assumption, I'm learning and having fun.

Maybe "you think" I know OS/2 programming, but I don't. It would be awesome if someone explain me and document how to indentify quick and easly the 16bit software. Feel free to write articles and blog post about it, I can post it on the EDM/2.

I also pity the poor person who wants to learn OS/2 programming with ArcaOS because there is no order or suggested tutorials on where to start, which samples to use and how to avoid the 1.x legacy.

BTW... I'm at a loss to understand why using the open-source 'wrc' which you have to find and install is somehow "better" than using 'rc' which is part of the OS and always available. It strikes me as a triumph of ideology over practicality.

I have this policy. Close source software is good, but open source software is better. why? Because you can improve open source software, while close source software's source code is inside someone's drawer. As far as a I know rc.exe is not open source, and it will never be improved, no matter how good or free of charge it is.
    "Good close source software is future abandonware, bad open source software can be improved with time."

I'm just going forward to compile the stuff I find, but everybody is welcome to identify which things are interesting and which things should be archived only for historical reference only.

I aprecciate your point of view that 'PM Window Template' and 'AV Browse' are no useful material. It will be a good thing to indentify the "non useful samples" and put some disclaimer or suggestion for an "hypothetical person who wants to learn OS/2 programming" to read that.

Rich, feel free to give your opinon if a sample is worthwhile or not, since "I DON'T KNOW".

Regards
« Last Edit: April 30, 2023, 09:48:38 pm by Martin Iturbide »
Martin Iturbide
OS2World NewsMaster
... just share the dream.

Dave Yeo

  • Hero Member
  • *****
  • Posts: 4805
  • Karma: +99/-1
    • View Profile
Re: Compiling a PM sample with GCC (2023)
« Reply #56 on: May 01, 2023, 01:21:52 am »
(Hint: looking up HEAPSIZE in any linker's reference manual would have clued you in - if only you had RTFM).

I just looked. The toolkits tools reference infers it is only for 16bit as there is MAXVAL which equals 64k.
The OW Linker guide says,
...
Quote
n specifies the size of the heap. The default heap size is 0 bytes. The maximum value of n is 65536 (64K) for 16-bit applications and 4G for 32-bit applications which is the maximum size of a physical segment. Actually, for a particular application, the maximum value of n is 64K or 4G less the size of group "DGROUP".

Testing with GCC, it does seem to be ignored with the DGROUP =250H in the map file. The documentation is not clear.

Martin Iturbide

  • OS2World NewsMaster
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4748
  • Karma: +41/-1
  • Your Friend Wil Declares...
    • View Profile
    • Martin's Personal Blog
Re: Compiling a PM sample with GCC (2023)
« Reply #57 on: May 01, 2023, 01:53:11 am »
Hi Rich

What is your problem? Why are you being this way today?
This is a forum, and I'm asking for help on something I don't know. You are a prolific WPS developer, but that does not give you the right to undermine my little effort to do something with people that actually want to help me.

RFTM (Read The Fucking Manual) is a rude answer which tells me a lot of your personality.

Bottom line, Martin: why should I put forth the effort if it looks like you won't even try (and asking other people to solve every problem you encounter is definitely _not_ "trying").

Move on, relax, go watch some birds outside and try to help other people on different threads. Please don't put any efforts, I don't want your help.

Regards
« Last Edit: May 01, 2023, 01:56:48 am by Martin Iturbide »
Martin Iturbide
OS2World NewsMaster
... just share the dream.

Rich Walsh

  • Sr. Member
  • ****
  • Posts: 337
  • Karma: +23/-0
  • ONU! (OS/2 is NOT Unix!)
    • View Profile
Re: Compiling a PM sample with GCC (2023)
« Reply #58 on: May 01, 2023, 01:54:20 am »
(Hint: looking up HEAPSIZE in any linker's reference manual would have clued you in - if only you had RTFM).

I just looked. The toolkits tools reference infers it is only for 16bit as there is MAXVAL which equals 64k.

OK, I apologize for overstating my case. I was remembering the details from the 'ilink' reference which states "The HEAPSIZE statement has no effect on a 32-bit OS/2 program.". This is something that Martin would certainly not have access to. In contrast, the ref for 'link386' says nothing about it being 16-bit only.

It simply confirms what I always say: if I don't look something up and/or test exactly what I'm saying, I always get it wrong. It applies to me, and sadly, a great many of other forum participants as well.

Lars

  • Hero Member
  • *****
  • Posts: 1272
  • Karma: +65/-0
    • View Profile
Re: Compiling a PM sample with GCC (2023)
« Reply #59 on: May 01, 2023, 01:59:34 am »
Maybe "you think" I know OS/2 programming, but I don't. It would be awesome if someone explain me and document how to indentify quick and easly the 16bit software. Feel free to write articles and blog post about it, I can post it on the EDM/2.

You are asking, here is the answer: an application is very likely a 16-bit application if:
1) the documentation mentions that it is for OS/2 1.3
2) the DEF file uses the HEAPSIZE keyword. That is completely ignored by any 32-bit linker
3) the makefile is calling "link.exe". That is a 16-bit linker from Microsoft. A 16-bit linker cannot create 32-bit executables
4) the suspiciously frequent use of USHORT/SHORT/unsigned short/signed short variables. A 32-bit application typically uses 32-bit variables which show as ULONG/LONG/unsigned long/signed long/int (where "int" is ambiguous: it`s 16-bit for a 16-bit compiler and 32-bit for a 32-bit compiler ...)
5) a window function with a signature of (HWND hwnd,USHORT msg,MPARAM mp1,MPARAM mp2): a 32-bit window function uses (HWND hwnd,ULONG msg,MPARAM mp1,MPARAM mp2)
6) the use of the _loadds keyword in code: the _loadds keyword explicitely loads the data selector of the application's data segment into the DS register. That is completely superfluous for a 32-bit application as the program loader loads the flat selector into DS before it starts the application and the application will never ever change that selector, it is completely opaque to the application.
As you can see, gcc.exe even gets confused about this keyword which it does not even know, it thinks it's a syntax error ...

In fact, the only code that still requires 16-bit are drivers, where "drivers" include physical/storage device drivers (.SYS, .ADD, .FLT, .DMD, .OS2) and file system drivers (.IFS). That's because the main entry points into these drivers are still all 16-bit. If someone talks about a 32-bit device driver then in reality, it's a hybrid of 16-bit and 32-bit code where you need "thunking" (the process of jumping from a 16-bit code segment to a 32-bit code segment or the other way around) to call 32-bit code from 16-bit code.
« Last Edit: May 01, 2023, 02:17:33 am by Lars »