OS/2, eCS & ArcaOS - Technical > Programming

Compiling a PM sample with GCC (2023)

<< < (51/52) > >>

Mentore:

--- Quote from: Martin Iturbide on November 16, 2023, 09:43:04 pm ---Hello.

I just get back to compile an extra little thing. It compiles and works.
 
Can you please give me a hand with this warning?

--- Quote ---gcc -Wall -Zomf -c -O2 pmstars.c -o pmstars.obj
pmstars.c: In function 'ClientWndProc':
pmstars.c:60:16: warning: variable 'my_timer' set but not used [-Wunused-but-set-variable]
   60 |   static ULONG my_timer;  /* System (PM) number indicating unique (system) timer number
      |                ^~~~~~~~
--- End quote ---

Regards

--- End quote ---

Hi Martin, the warning simply states the my_timer variable is never used. Just to be extra sure, search for it into the source code and if it is really never used (as I expect to happen), you can safely comment out / delete the statement.

Mentore

Martin Iturbide:
Hello

If I comment :
 line 60 // static ULONG my_timer;

and
 line 98 // my_timer=WinStartTimer( hab, hwnd, 0L, (ULONG)50 );

It will compile without errors, runs, but the animation will not work.

I guess I will leave this warning as it is.

Regards

Martin Iturbide:
Hello

Here it is another one. I tried to convert Fatbits (pixel magnifier program) from the OS/2 1.1 API by changing some WinQuery.. functions to PrfQuery.... Removed the warnings. I ignored the ASM code that seemed only to create the DLL, and didn't create the DLL, I embedded it to the EXE. 

It compiles without warnings, it loads, shows the magnified pixels, but it does not refresh the screen according the position of the cursor. If I maximize and reduce a window, it will refresh the magnifier image.

Regards

Mentore:

--- Quote from: Martin Iturbide on November 17, 2023, 03:35:12 pm ---Hello

If I comment :
 line 60 // static ULONG my_timer;

and
 line 98 // my_timer=WinStartTimer( hab, hwnd, 0L, (ULONG)50 );

It will compile without errors, runs, but the animation will not work.

I guess I will leave this warning as it is.

Regards

--- End quote ---

which is the right thing to do, Martin, as the variable is of course needed. To remove the warning you may try to do something with it like this:


--- Code: ---my_timer++;
my_timer--;

--- End code ---

before calling WinStartTimer, so that the compiler thinks we have done something on it, or maybe search for some
--- Code: ---#pragma
--- End code ---
statement to avoid the warning. Not sure about it, since I'm no GCC expert at all.

Mentore

Alex Taylor:

--- Quote from: Martin Iturbide on November 16, 2023, 09:43:04 pm ---Can you please give me a hand with this warning?

--- Quote ---gcc -Wall -Zomf -c -O2 pmstars.c -o pmstars.obj
pmstars.c: In function 'ClientWndProc':
pmstars.c:60:16: warning: variable 'my_timer' set but not used [-Wunused-but-set-variable]
   60 |   static ULONG my_timer;  /* System (PM) number indicating unique (system) timer number
      |                ^~~~~~~~
--- End quote ---

--- End quote ---

Calling WinStopTimer on it at cleanup time might be the most "proper" way of dealing with that.  However, a quicker and cheaper way of eliminating the warning is probably to add:


--- Code: ---if ( my_timer ) {;}   /* stop compiler from complaining */
--- End code ---

after the call to WinStartTimer.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version