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

Martin Iturbide

  • OS2World NewsMaster
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4677
  • Karma: +41/-1
  • Your Friend Wil Declares...
    • View Profile
    • Martin's Personal Blog
Re: Compiling a PM sample with GCC (2023)
« Reply #120 on: May 26, 2023, 06:11:06 pm »
Hello

On this one I'm not sure what I did wrong.
Quote
In file included from C:/usr/include/os2.h:39,
                 from cnrez.c:59:
C:/usr/include/os2emx.h:10843:3: error: unknown type name 'PDLGTEMPLATE'
10843 |   PDLGTEMPLATE pdlgtPage;
      |   ^~~~~~~~~~~~

Here it is the original one just in case: https://github.com/OS2World/DEV-SAMPLES-C-PM-Containers/tree/master/cnrez

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

Dave Yeo

  • Hero Member
  • *****
  • Posts: 4761
  • Karma: +98/-1
    • View Profile
Re: Compiling a PM sample with GCC (2023)
« Reply #121 on: May 27, 2023, 02:21:18 am »
Looking at os2emx.h, the typedef is guarded by #if defined (INCL_WINDIALOGS) so the fix is,
Code: [Select]
--- CNREZ.C.orig        2023-05-26 17:16:48.000000000 -0700
+++ CNREZ.C     2023-05-26 17:16:14.000000000 -0700
@@ -51,6 +51,7 @@
 #define  INCL_WINSTDCNR
 #define  INCL_WINSTDDLGS
 #define  INCL_WINWINDOWMGR
+#define  INCL_WINDIALOGS

 /**********************************************************************/
 /*----------------------------- INCLUDES -----------------------------*/

Martin Iturbide

  • OS2World NewsMaster
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4677
  • Karma: +41/-1
  • Your Friend Wil Declares...
    • View Profile
    • Martin's Personal Blog
Re: Compiling a PM sample with GCC (2023)
« Reply #122 on: May 27, 2023, 04:29:35 am »
Martin Iturbide
OS2World NewsMaster
... just share the dream.

Martin Iturbide

  • OS2World NewsMaster
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4677
  • Karma: +41/-1
  • Your Friend Wil Declares...
    • View Profile
    • Martin's Personal Blog
Re: Compiling a PM sample with GCC (2023)
« Reply #123 on: May 28, 2023, 04:52:27 pm »
Hi

Now I'm moving forward with the  C PM Samples from the IBM toolkit (version 4.5).
I started with CLIPBDR.

I have this warnings that I'm not sure how to solve.

Quote
gcc -Wall -Zomf -c -O2 clipbrd.c -o clipbrd.obj
clipbrd.c:160:25: warning: missing braces around initializer [-Wmissing-braces]
  160 | DRIVDATA    drvdata[] = {44L, 0L, "DISPLAY", 0L};
      |                         ^
      |                          {                   { }}
clipbrd.c: In function 'PaintRoutine':
clipbrd.c:1042:12: warning: variable 'RC' set but not used [-Wunused-but-set-variable]
 1042 |    BOOL    RC;
      |            ^~
clipbrd.c: In function 'SetSysMenu':
clipbrd.c:1580:7: warning: case label value exceeds maximum value for type
 1580 |       case SC_MOVE:
      |       ^~~~
clipbrd.c:1581:7: warning: case label value exceeds maximum value for type
 1581 |       case SC_CLOSE:
      |       ^~~~


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

Dave Yeo

  • Hero Member
  • *****
  • Posts: 4761
  • Karma: +98/-1
    • View Profile
Re: Compiling a PM sample with GCC (2023)
« Reply #124 on: May 28, 2023, 08:35:29 pm »
Some of these warnings seem bogus. I played with the braces in the first warning, the warning only changed. The RC warning is obviously wrong as it is used a few lines down and removing it results in an error about it missing.
The case ones I don't understand, thought case was a keyword. They're the only warnings that show if -Wall is removed from CFLAGS.

Flashback

  • Newbie
  • *
  • Posts: 6
  • Karma: +3/-1
    • View Profile
Re: Compiling a PM sample with GCC (2023)
« Reply #125 on: May 28, 2023, 10:14:01 pm »
Not having tried to compile this:
  • 'drvdata' is declared as an array. So the initialisation should be something like {{44, 0, "DISPLAY", ""}} or {{44, 0, "DISPLAY", {0}}}  I fail to see, why they use 'L' suffixes in the original source though.
  • 'RC' is indeed not used. In line 1076 a value gets assigned, but nobody bothers to do something with it.
  • 'SC_MOVE' and 'SC_CLOSE' have values of 0x800X. They are propagated to (signed)integers by the compiler. Thus they indeed exceed that range of variable 'id' in the switch statement, which is (signed) short.
Modern compilers like the gcc rarely produce bogus warnings. In almost any case these warnings have a reason. And -Wall should be considered as your friend, not your enemy. Old code like this will often trigger warnings when using recent tools.

Martin Iturbide

  • OS2World NewsMaster
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4677
  • Karma: +41/-1
  • Your Friend Wil Declares...
    • View Profile
    • Martin's Personal Blog
Re: Compiling a PM sample with GCC (2023)
« Reply #126 on: May 29, 2023, 02:33:14 am »
Thanks Flashback.

-  {{44, 0, "DISPLAY", {0}}} - Fixed the warning.
- I commented the RC declaration and assignation - Fixed the warning

I'm not sure what can I change for 'SC_MOVE' and 'SC_CLOSE' warnings.

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

Dave Yeo

  • Hero Member
  • *****
  • Posts: 4761
  • Karma: +98/-1
    • View Profile
Re: Compiling a PM sample with GCC (2023)
« Reply #127 on: May 29, 2023, 03:05:47 am »
Changing Id to a LONG at line 1562 is one solution.
As for the RC, ideally there should be some error checking there.
Edit: while the documentation shows using rc, the example doesn't and considering the possible errors, guess it isn't really needed to do error checking
« Last Edit: May 29, 2023, 03:12:18 am by Dave Yeo »

Lars

  • Hero Member
  • *****
  • Posts: 1264
  • Karma: +65/-0
    • View Profile
Re: Compiling a PM sample with GCC (2023)
« Reply #128 on: May 29, 2023, 09:11:27 am »
The warning about RC is perfectly ok. It is being assigned a value, removing it will obviously lead to an error. But the assignment does not result in any consequences, hence the warning.
However, I often also do that in order to ease source code debugging and if an error would be very unlikely. It's easier to look at a variable then to look at registers (a function always places its result in EAX).
« Last Edit: May 29, 2023, 09:13:46 am by Lars »

Martin Iturbide

  • OS2World NewsMaster
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4677
  • Karma: +41/-1
  • Your Friend Wil Declares...
    • View Profile
    • Martin's Personal Blog
Re: Compiling a PM sample with GCC (2023)
« Reply #129 on: May 29, 2023, 05:37:20 pm »
Thanks for your help

CLIPBRD now compiles without warnings.
https://github.com/OS2World/DEV-SAMPLES-C-PM-CLIPBRD

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

Martin Iturbide

  • OS2World NewsMaster
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4677
  • Karma: +41/-1
  • Your Friend Wil Declares...
    • View Profile
    • Martin's Personal Blog
Re: Compiling a PM sample with GCC (2023)
« Reply #130 on: May 29, 2023, 06:08:18 pm »
Also...
https://github.com/OS2World/DEV-SAMPLES-C-PM-Dialog
Removed warnings and works with gcc.

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

Martin Iturbide

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

https://github.com/OS2World/DEV-SAMPLES-C-PM-STDWND-Hello
This one was also easy to remove the warnings.

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

Martin Iturbide

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

Now I'm trying https://github.com/OS2World/DEV-DIVE-Show
It compiles, but when I run it, it close without any message on popuplog.

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

Dave Yeo

  • Hero Member
  • *****
  • Posts: 4761
  • Karma: +98/-1
    • View Profile
Re: Compiling a PM sample with GCC (2023)
« Reply #133 on: May 31, 2023, 06:04:23 pm »
It's weird, supposed to show the help with no parameters,
Code: [Select]
int main ( int argc, char *argv[] )
   {
   HFILE hFile;
   ULONG ulNumBytes, ulFileLength;
   PBYTE pbImageBottom, pbBMP;
   ULONG rc;
   PBITMAPFILEHEADER2 pbmfHeader;

   /* Check the number of command line arguments.                            */
   if ( argc != 2 )
      {
      printf ( "usage: SHOW filein.bmp\n" );
      printf ( "   Jams ab 8-bit bitmap image directly to the upper\n" );
      printf ( "   left corner of the screen.  Clipping is not exemplified.\n" )
;
      printf ( "   Note this code example works only if:\n" );
      printf ( "      1) SMVDD.SYS is installed propery in four CONFIG.SYS\n" );
      printf ( "         (You can get this from the MMPM/2 install disks), and\n" );
      printf ( "      2) Your adapter has an aperture enabled, and\n" );
      printf ( "      3) Your adapter is in 8, 16, or 24 bit bit color mode, and\n" );
      printf ( "      4) Your bitmap is 8-bit only (i.e. this does no color conv
ersion).\n" );
      return ( 0 );
      }

Looks like it also depends on SMVDD.SYS, which I don't see on my system

Martin Iturbide

  • OS2World NewsMaster
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4677
  • Karma: +41/-1
  • Your Friend Wil Declares...
    • View Profile
    • Martin's Personal Blog
Re: Compiling a PM sample with GCC (2023)
« Reply #134 on: May 31, 2023, 07:06:08 pm »
Hi.
I also don't have "SMVDD.SYS"

I found a reference on this book: https://komh.github.io/os2books/pdf/sg244627.pdf
(The Guide to OS/2 Warp Device Drivers. December 1995)

"This driver provides DOS and WIN-OS/2 digital video support. If you do not use DOS or WIN-OS/2 that require digital video support you can remove this driver from CONFIG.SYS."

Checking the readme it says:

Quote
SHOW.ZIP is an exectuable and source code which shows you how to
use DIVE (Direct Interface to Video Extensions) to directly
access the video display. It is useful for games and other apps
which need SPEED!  You actually write directly to video memory.

It contains the following items:

L        CMD  sample linker file
DIRECT   H    fucntion prototypes
SHOW     EXE  program to display a bitmap
SHOW     C    source code for DIVE interface
SMVDD    SYS  Device driver to map addresses
CHICK    BMP  Bitmap
DIRECT   C    More DIVE code
C        CMD  Compiler batch file.

SMVDD.SYS - Device driver to map addresses ? uhm?? It does not mach the description.

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