Fix build issues for matched functions in the Melee decompilation project.
You are an expert at fixing build issues in the Melee decompilation project. This skill focuses on resolving compilation errors AFTER a function has been matched to its assembly - the matching work is done, but the build is broken.
Use /decomp-fixup when:
UNK_RET/UNK_PARAMS that need real signaturesUse /decomp instead when:
# Check state for functions that may need build fixes
melee-agent state status
# Look for functions in "committed" state that may have broken builds
# Or check functions with known issues
melee-agent state status <function_name>
cd <worktree> && python configure.py && ninja
The build requires function prototypes by default (same as CI). Common error types:
| Error Pattern | Cause | Solution |
|---|---|---|
implicit declaration of function |
Missing prototype | Add to header |
conflicting types for 'func' |
Header/impl mismatch | Fix header signature |
too few arguments to function |
Signature changed | Update callers |
too many arguments to function |
Signature changed | Update callers |
incompatible pointer type |
Type mismatch | Fix types |
unknown type name |
Missing include/typedef | Add include |
Function headers are typically in:
melee/include/melee/<module>/forward.h # Forward declarations
melee/include/melee/<module>/<file>.h # Full declarations
Example paths:
ft_* functions: melee/include/melee/ft/forward.h or melee/include/melee/ft/ftcommon.hlb* functions: melee/include/melee/lb/forward.hgr* functions: melee/include/melee/gr/forward.hWhen you change a function's signature, find and fix all callers:
grep -r "function_name" <worktree>/src/melee/
grep -r "function_name" <worktree>/include/melee/
Problem: Header has stub declaration, implementation has real signature.
// Before (in header - stub declaration):
/* 0D7268 */ UNK_RET ftCo_800D7268(UNK_PARAMS);
// After (matches implementation):
/* 0D7268 */ void ftCo_800D7268(Fighter* fp, s32 arg1);
Steps:
src/melee//* address */ comment if present// Before:
UNK_RET func(s32 x);
// After (if implementation returns void):
void func(s32 x);
// After (if implementation returns a value):
s32 func(s32 x);
Note: M2C_UNK can be used as a placeholder return type when the actual type is still being determined.
// Before:
void func(UNK_PARAMS);
// After (from implementation):
void func(HSD_GObj* gobj, s32 action_id, float frame);
When a signature changes from void foo(void) to void foo(s32 arg):
// Before (caller):
foo();
// After (caller - must pass argument):
foo(0); // Or appropriate value based on context
Finding the right argument:
bl instructionHeaders need parameter names for documentation, but types must match:
// Before (missing names):
void func(s32, float, HSD_GObj*);
// After (with names):
void func(s32 action, float frame, HSD_GObj* gobj);
If a struct field type is wrong:
// Workaround in code (temporary fix):
#define DMG_X1898(fp) (*(float*)&(fp)->dmg.x1898)
// Better: Fix the struct definition in the header
// Before:
s32 x1898;
// After:
float x1898;
# 1. Check build error
cd <worktree> && ninja 2>&1 | head -50
# 2. Find header location
grep -r "function_name" <worktree>/include/
# 3. Find implementation
grep -r "function_name" <worktree>/src/melee/
# 4. Compare signatures and fix header
# 5. Find and fix callers if signature changed
grep -r "function_name(" <worktree>/src/melee/
# 6. Rebuild and verify
ninja
# 1. Get full error list
cd <worktree> && python configure.py && ninja 2>&1 | tee build_errors.txt
# 2. Categorize errors
grep "conflicting types" build_errors.txt
grep "implicit declaration" build_errors.txt
grep "too few arguments" build_errors.txt
# 3. Fix in dependency order (headers first, then callers)
After fixing build issues:
# Verify build passes
cd <worktree> && python configure.py && ninja
# Commit the fix (in the worktree)
git add -A
git commit -m "Fix build: update <function> signature in header"
Commit message patterns:
Fix build: update ftCo_800D7268 signature in headerFix build: add missing prototype for lbColl_80008440Fix build: update callers for gr_800123AB signature changeUNK_RET/UNK_PARAMS left for functions you've implementedCommon types in Melee:
s8, s16, s32 - signed integersu8, u16, u32 - unsigned integersf32, f64 - floatsBOOL - boolean (actually s32)HSD_GObj* - game object pointerFighter* - fighter state pointerVec3 - 3D vector structM2C_UNK - unknown type placeholder| Issue | Solution |
|---|---|
| Can't find header | Check include/melee/<module>/forward.h |
| Multiple declarations | Search all .h files, update all of them |
| Caller in different worktree | Note the file, fix when you work on that subdirectory |
| Circular dependency | May need forward declaration |
| Build still fails after fix | Run ninja -t clean && ninja for full rebuild |