Skip to content

Commit

Permalink
check generics to avoid issue with different types of args
Browse files Browse the repository at this point in the history
  • Loading branch information
aodinokov committed Sep 17, 2024
1 parent fcf6932 commit 8fd1522
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions examples/c_print_args_alt/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ enum x {
xTwo = 2,
xMinusOne = -1,
};
int test_function4_with_enum_args(enum x arg0, enum x arg1, enum x arg2) {
int test_function4_with_enum_args(enum x arg0, enum x arg1, enum x arg2, list_t x) {
return 0;
}
METAC_GSYM_LINK(test_function4_with_enum_args);
Expand Down Expand Up @@ -76,8 +76,8 @@ int main() {

printf("fn returned: %i\n", METAC_WRAP_FN_RES(p_tagmap, my_printf, "%d %d\n", 10, 22));

printf("fn returned: %i\n", METAC_WRAP_FN_RES(p_tagmap, test_function4_with_enum_args, xOne, xTwo, xMinusOne));
printf("fn returned: %i\n", METAC_WRAP_FN_RES(p_tagmap, test_function4_with_enum_args, 1, 2, -1));
printf("fn returned: %i\n", METAC_WRAP_FN_RES(p_tagmap, test_function4_with_enum_args, xOne, xTwo, xMinusOne, *p_list));
printf("fn returned: %i\n", METAC_WRAP_FN_RES(p_tagmap, test_function4_with_enum_args, 1, 2, -1, *p_list));

metac_tag_map_delete(p_tagmap);
return 0;
Expand Down
4 changes: 2 additions & 2 deletions examples/c_print_args_alt/print_args.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ static int _process_unspecified_params(
/* ensure arg isn't string constant */ \
char _s_arg[] = _QSTRING_ARG(MR_FIRST(args)); \
if (_s_arg[0] == '\"') { \
/* TODO: can't handle structs, va_list as arguments because of this line */ \
char * s = ((char*)MR_FIRST(args)); \
/* can't handle structs, va_list as arguments because of this line */ \
char * s = ((char*)_Generic(MR_FIRST(args), char*: MR_FIRST(args), default: NULL)); \
memcpy(metac_value_addr(p_param_value), &s, param_entry_byte_size); \
} else { \
memcpy(metac_value_addr(p_param_value), &_x_val, param_entry_byte_size); \
Expand Down

0 comments on commit 8fd1522

Please sign in to comment.