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

Martin Iturbide

  • OS2World NewsMaster
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4146
  • Karma: +39/-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: 4325
  • Karma: +83/-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: 4146
  • Karma: +39/-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: 4146
  • Karma: +39/-1
  • Your Friend Wil Declares...
    • View Profile
    • Martin's Personal Blog
Re: Compiling a PM sample with GCC (2023)
« Reply #123 on: Today at 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: 4325
  • Karma: +83/-1
    • View Profile
Re: Compiling a PM sample with GCC (2023)
« Reply #124 on: Today at 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: 2
  • Karma: +0/-0
    • View Profile
Re: Compiling a PM sample with GCC (2023)
« Reply #125 on: Today at 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.