Skip to content
Snippets Groups Projects

Strike null-pointer-arithmetic error in BUFFER_OFFSET

Merged mazmazz requested to merge mazmazz_/SRB2:buffer-offset-fix into master

Compiling SRB2 under Xcode 11.5 complains about BUFFER_OFFSET, as seen in this build log:

[ 97%] Building C object src/sdl/CMakeFiles/SRB2SDL2.dir/__/hardware/r_opengl/r_opengl.c.o
/Users/travis/build/mazmazz/SRB2/src/hardware/r_opengl/r_opengl.c:2083:54: error: arithmetic on a null pointer treated as a cast from integer to pointer is a GNU extension [-Werror,-Wnull-pointer-arithmetic]
                                pglVertexPointer(3, GL_SHORT, sizeof(vbotiny_t), BUFFER_OFFSET(0));
                                                                                 ^~~~~~~~~~~~~~~~
/Users/travis/build/mazmazz/SRB2/src/hardware/r_opengl/r_opengl.c:1927:39: note: expanded from macro 'BUFFER_OFFSET'
#define BUFFER_OFFSET(i) ((char*)NULL + (i))
                          ~~~~~~~~~~~ ^

Monster Iestyn discovered an alternate define for this variable, seen here and used in this MR.

This compiles successfully and no crashes occur in runtime, as far as I've tested.

Merge request reports

Checking pipeline status.

Approval is optional

Merged by avatar (Apr 15, 2025 6:03am UTC)

Merge details

  • Changes merged into with 70eb5ba6.
  • Deleted the source branch.

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
Please register or sign in to reply
Loading