-
Notifications
You must be signed in to change notification settings - Fork 14
Open
Description
When generating C glue code with --c flag, fixed-size array parameters are rendered with incorrect syntax. The array size specifier [N] is placed before the parameter name instead of after.
Reproduction
Input header:
#include <stdint.h>
typedef struct {
void *ptr;
} Context;
void processWithBounds(Context ctx, int64_t bounds[4]);Command:
bindgen --header bug2-array-parameter.h --package test.native --link-name test --llvm-bin $LLVM_BIN_PATH --c --flavour scala-native05 --c-import "bug2-array-parameter.h" --clang-include .Generated output (invalid):
void __sn_wrap_test_native_processWithBounds(Context *ctx, int64_t[4] bounds) {
processWithBounds(*ctx, bounds);
};Expected output (valid C):
void __sn_wrap_test_native_processWithBounds(Context *ctx, int64_t bounds[4]) {
processWithBounds(*ctx, bounds);
}Or equivalently (since arrays decay to pointers in function parameters):
void __sn_wrap_test_native_processWithBounds(Context *ctx, int64_t *bounds) {
processWithBounds(*ctx, bounds);
}Compiler Error
error: expected ')'
void __sn_wrap_test_native_processWithBounds(Context *ctx, int64_t[4] bounds)
^
Analysis
In C, array parameter declarations require the parameter name before the size specifier:
- Invalid:
int64_t[4] bounds - Valid:
int64_t bounds[4]orint64_t *bounds
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels