Skip to content

Commit 06c11aa

Browse files
committed
fix(generator): handle ptrdiff_t type correctly in C type mapping
Adds special case handling for ptrdiff_t in getCType function to preserve its type name rather than converting it to a Go equivalent. This fixes type mismatch errors on macOS where ptrdiff_t is a distinct type from int64_t despite having the same size.
1 parent e8b72a3 commit 06c11aa

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

functions.gen.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14172,7 +14172,7 @@ func AVImageCopyPlane(dst unsafe.Pointer, dstLinesize int, src unsafe.Pointer, s
1417214172
size (i.e. 64) to get improved performance.
1417314173
*/
1417414174
func AVImageCopyPlaneUcFrom(dst unsafe.Pointer, dstLinesize int64, src unsafe.Pointer, srcLinesize int64, bytewidth int64, height int) {
14175-
C.av_image_copy_plane_uc_from((*C.uint8_t)(dst), C.int64_t(dstLinesize), (*C.uint8_t)(src), C.int64_t(srcLinesize), C.int64_t(bytewidth), C.int(height))
14175+
C.av_image_copy_plane_uc_from((*C.uint8_t)(dst), C.ptrdiff_t(dstLinesize), (*C.uint8_t)(src), C.ptrdiff_t(srcLinesize), C.ptrdiff_t(bytewidth), C.int(height))
1417614176
}
1417714177

1417814178
// --- Function av_image_copy ---

internal/generator/generator.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,13 @@ func getCType(typeName string, goType string) string {
8787
return "char"
8888
}
8989

90+
// Special case: ptrdiff_t and size_t must be preserved
91+
// On macOS, ptrdiff_t is a distinct type from int64_t even though they're the same size
92+
// Using C.int64_t instead of C.ptrdiff_t causes type mismatch errors
93+
if typeName == "ptrdiff_t" {
94+
return "ptrdiff_t"
95+
}
96+
9097
// Map Go types to their correct C types
9198
// Returns the type name to use after "C." in generated code
9299
switch goType {

0 commit comments

Comments
 (0)