Skip to content

LoadTPage: definition (u_int*) and declaration (u_long*) disagree, fails to compile as C on LP64 #13

Description

@tobyrg

Summary

LoadTPage's definition and its declaration disagree on the pointer type of the first parameter — u_int* in the implementation vs. u_long* in the header. This compiles fine on platforms/ABIs where u_int and u_long are the same width, but is a hard "conflicting types" error under strict C on any LP64 platform (e.g. 64-bit Linux/glibc), where int is 32-bit and long is 64-bit.

Where

Declaration, include/psx/libgpu.h:

extern u_short LoadTPage(u_long*pix, int tp, int abr, int x, int y, int w, int h);

Definition, src/psx/LIBGPU.C:

u_short LoadTPage(u_int* pix, int tp, int abr, int x, int y, int w, int h)

Repro

Compiling src/psx/LIBGPU.C as C (not C++) on a 64-bit Linux host with GCC:

error: conflicting types for ‘LoadTPage’; have ‘u_short(u_int *, int, int, int, int, int, int)’
note: previous declaration of ‘LoadTPage’ with type ‘u_short(u_long *, int, int, int, int, int, int)’

Suggested fix

Make the definition's parameter type match the header's (u_long* pix), or vice versa — whichever reflects the actual intended pointer width.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions