source-sdk-2013 icon indicating copy to clipboard operation
source-sdk-2013 copied to clipboard

[HL2] Fix Linux compilation

Open Blixibon opened this issue 11 months ago • 1 comments

This pull request fixes HL2 and Episodic projects not compiling on Linux in the master branch after the latest commit.

Blixibon avatar Feb 20 '25 16:02 Blixibon

3 lines of code to fix that is crazy

lucasdaweb95 avatar Feb 20 '25 21:02 lucasdaweb95

Isn't NULL by default defined? If it isn't why not just add these lines of code to some include?

#ifdef _LINUX || _OSX
#define NULL 0
#endif

SrcEngGuy avatar Mar 10 '25 11:03 SrcEngGuy

Isn't NULL by default defined? If it isn't why not just add these lines of code to some include?

#ifdef _LINUX || _OSX
#define NULL 0
#endif

The issue was that NULL is ambiguous in these cases, which causes errors in the updated SDK.

For example:

game/shared/hl2/hl2_gamerules.cpp: In function 'CAmmoDef* GetAmmoDef()':
game/shared/hl2/hl2_gamerules.cpp:1817:84: error: call of overloaded 'AddAmmoType(const char [8], int, AmmoTracer_t, NULL, NULL, NULL, int, int)' is ambiguous
 1817 |   def.AddAmmoType("Battery",   DMG_CLUB,     TRACER_NONE,   NULL, NULL, NULL, 0, 0 );
      |                                                                                    ^
In file included from game/shared/hl2/hl2_gamerules.cpp:10:
game/shared/ammodef.h:86:10: note: candidate: 'void CAmmoDef::AddAmmoType(const char*, int, int, int, int, int, float, int, int, int)'
   86 |  void    AddAmmoType(char const* name, int damageType, int tracerType, int plr_dmg, int npc_dmg, int carry, float physicsForceImpulse, int nFlags, int minSplashSize = 4, int maxSplashSize = 8 );
      |          ^~~~~~~~~~~
In file included from game/shared/hl2/hl2_gamerules.cpp:10:
game/shared/ammodef.h:87:10: note: candidate: 'void CAmmoDef::AddAmmoType(const char*, int, int, const char*, const char*, const char*, float, int, int, int)'
   87 |  void    AddAmmoType(char const* name, int damageType, int tracerType, char const* plr_cvar, char const* npc_var, char const* carry_cvar, float physicsForceImpulse, int nFlags, int minSplashSize = 4, int maxSplashSize = 8 );
      |          ^~~~~~~~~~~

Blixibon avatar Mar 12 '25 20:03 Blixibon