Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build warnings on Debian #18

Closed
abalfoort opened this issue Jun 9, 2023 · 3 comments
Closed

Build warnings on Debian #18

abalfoort opened this issue Jun 9, 2023 · 3 comments

Comments

@abalfoort
Copy link
Contributor

Building 3zb2 on Debian 12 there are lots of warnings.
Most of them are easy to remedy:

[  3%] Building C object CMakeFiles/game.dir/src/bot/fire.c.o
/home/arjen/dev/Q2RTX/workingdir/_yquake2/3zb2/src/bot/fire.c: In function ‘B_UseHyperBlaster’:
/home/arjen/dev/Q2RTX/workingdir/_yquake2/3zb2/src/bot/fire.c:539:11: warning: variable ‘zc’ set but not used [-Wunused-but-set-variable]
  539 |  zgcl_t  *zc;
      |           ^~

But this one I don't know how to resolve:

In file included from /home/arjen/dev/Q2RTX/workingdir/_yquake2/3zb2/src/g_ctf.c:1:
/home/arjen/dev/Q2RTX/workingdir/_yquake2/3zb2/src/g_ctf.c: In function ‘SelectCTFSpawnPoint’:
/home/arjen/dev/Q2RTX/workingdir/_yquake2/3zb2/src/header/local.h:537:17: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
  537 | #define FOFS(x) (int)&(((edict_t *)0)->x)
      |                 ^
/home/arjen/dev/Q2RTX/workingdir/_yquake2/3zb2/src/g_ctf.c:410:31: note: in expansion of macro ‘FOFS’
  410 |  while ((spot = G_Find (spot, FOFS(classname), cname)) != NULL)
      |                               ^~~~

I've been searching on stackoverflow.com but couldn't find something that could help in this case.

Anybody has an idea?

@Yamagi
Copy link
Member

Yamagi commented Jun 10, 2023

The games can be divided into three groups:

  • A full cleanup was applied baseq2, xatrix and rogue. They should be as good as it gets.
  • ctf has gotten a lesser amount of cleanup, but enough to be fine.
  • Everything else is handled on a best effort base. It might be good enough but it's far from being fine.

3zb2 falls into the later group. I hacked this "port" in two hours. I did just enough changes that it builds with a modern toolchain and works good enough for multiplayer testing.

In file included from /home/arjen/dev/Q2RTX/workingdir/_yquake2/3zb2/src/g_ctf.c:1:
/home/arjen/dev/Q2RTX/workingdir/_yquake2/3zb2/src/g_ctf.c: In function ‘SelectCTFSpawnPoint’:
/home/arjen/dev/Q2RTX/workingdir/_yquake2/3zb2/src/header/local.h:537:17: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
  537 | #define FOFS(x) (int)&(((edict_t *)0)->x)
      |                 ^
/home/arjen/dev/Q2RTX/workingdir/_yquake2/3zb2/src/g_ctf.c:410:31: note: in expansion of macro ‘FOFS’
  410 |  while ((spot = G_Find (spot, FOFS(classname), cname)) != NULL)
      |                               ^~~~

This means that the code isn't 64 bit clean. On x86 / i386 pointers and integers were 32 bit long. It was a common pattern to cast pointers into integers, the code exactly does this. It cannot work on 64 bit platforms like Linux and Unix were pointers are 64 bit and integers stayed at 32 bits. In this case you can properly use size_t instead: https://github.com/yquake2/xatrix/blob/master/src/header/local.h#L493

3zb2 is under the SDK license which is incompatible to the GPL. You can copy code from the other addons but not from the GPL licensed YQ2 itself and ctf.

@DanielGibson
Copy link
Member

note that the warnings should be harmless - an unused variable doesn't matter at all, and the FOFS macro is used to calculate the offset of a member of the edict_t struct within that struct, which will easily fit into a 32bit int (as sizeof(edict_t) is a lot smaller than 2GB). Would probably be cleaner to use offsetof() than hacking a custom offsetof-like thing, but it should work anyway..

@abalfoort
Copy link
Contributor Author

abalfoort commented Jun 11, 2023

I suspected it would be a 32-bit/64-bit issue as it was mentioned on stackoverflow but your explanations I can work with. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants