fix(cl): handle plain char on unsigned-char targets

Abierto
#1,150 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
55/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
c, go

Línea de trabajo

Start with the C type mapping and macro argument generation implicated by the CXType_Char_U versus CXType_UChar distinction. Reproduce on Linux arm64 with the stated CI command, then compare generated output for cl/_testc/function and the cl/_testc/macrofn_auto/in.h fixture. Done means plain char bindings and forwarding macro string arguments generate successfully with behavior that respects target char signedness.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

On Linux arm64, Clang reports plain C char as CXType_Char_U. llcppg currently maps Char_U and explicit unsigned char (CXType_UChar) together to Go uint8. This makes ordinary char * bindings incompatible with c.Str, which returns *c.Char.

Reproduction

On Linux arm64, run the existing CI command:

llgo test -v -coverpkg=./... -covermode=atomic -coverprofile=coverage.txt ./...

The existing cl/_testc/macrofn_auto/in.h fixture contains this forwarding macro:

#define ZLIB_VERSION "1.3.1"
int deflateInit_(z_streamp strm, int level, const char *version, int stream_size);
#define z_deflateInit(strm, level) \
    deflateInit_((strm), (level), ZLIB_VERSION, sizeof(z_stream))

Actual behavior

The const char *version parameter is mapped to *uint8, but the automatically generated macro call passes c.Str("1.3.1"), whose type is *c.Char. Generation panics because *c.Char cannot be passed as *uint8.

The generated output also differs from the existing fixtures for ordinary char * declarations. For example, cl/_testc/function produces Xprintf(fmt *uint8, ...) while the expected output uses *c.Char.

Expected behavior

Plain char bindings and string arguments in forwarding macros should work on Linux arm64 without a generation panic. Handling should account for the distinction between plain char and explicit unsigned char, as well as the target's char signedness.

Environment and evidence

Reproduced on Ubuntu 24.04 arm64 with LLVM 22, LLGo 1.0.8, Go 1.27.0, and github.com/goplus/lib v0.7.1, based on main commit b36e6307e67751c67654da37297ab654ef0ef0e3. The Linux arm64 job added in #1149 reproduces the failure: https://github.com/goplus/llcppg/actions/runs/42154256948/job/127684520612

Lenguaje dominante
Go
Estrellas
40
Forks
13
Merge medio
2 h 48 min
PR fusionados (30 d)
109

Preparar el entorno

Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de goplus/llcppg

Todos los issues de goplus/llcppg

Issues similares

Más issues de Go

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.