diff --git a/arraylist.c b/arraylist.c index d8e12d1..7e12d98 100644 --- a/arraylist.c +++ b/arraylist.c @@ -166,13 +166,13 @@ int array_list_add(struct array_list *arr, void *data) return 0; } -void array_list_sort(struct array_list *arr, int (*compar)(const void *, const void *)) +void array_list_sort(struct array_list *arr, int(__cdecl *compar)(const void *, const void *)) { qsort(arr->array, arr->length, sizeof(arr->array[0]), compar); } void *array_list_bsearch(const void **key, struct array_list *arr, - int (*compar)(const void *, const void *)) + int(__cdecl *compar)(const void *, const void *)) { return bsearch(key, arr->array, arr->length, sizeof(arr->array[0]), compar); } diff --git a/arraylist.h b/arraylist.h index f541706..65b8acf 100644 --- a/arraylist.h +++ b/arraylist.h @@ -68,10 +68,11 @@ extern int array_list_add(struct array_list *al, void *data); extern size_t array_list_length(struct array_list *al); -extern void array_list_sort(struct array_list *arr, int (*compar)(const void *, const void *)); +extern void array_list_sort(struct array_list *arr, + int(__cdecl *compar)(const void *, const void *)); extern void *array_list_bsearch(const void **key, struct array_list *arr, - int (*compar)(const void *, const void *)); + int(__cdecl *compar)(const void *, const void *)); extern int array_list_del_idx(struct array_list *arr, size_t idx, size_t count); diff --git a/json_object.c b/json_object.c index 9df5809..b50a33d 100644 --- a/json_object.c +++ b/json_object.c @@ -1463,7 +1463,8 @@ struct array_list *json_object_get_array(const struct json_object *jso) } } -void json_object_array_sort(struct json_object *jso, int (*sort_fn)(const void *, const void *)) +void json_object_array_sort(struct json_object *jso, + int(__cdecl *sort_fn)(const void *, const void *)) { assert(json_object_get_type(jso) == json_type_array); array_list_sort(JC_ARRAY(jso)->c_array, sort_fn); @@ -1471,7 +1472,7 @@ void json_object_array_sort(struct json_object *jso, int (*sort_fn)(const void * struct json_object *json_object_array_bsearch(const struct json_object *key, const struct json_object *jso, - int (*sort_fn)(const void *, const void *)) + int(__cdecl *sort_fn)(const void *, const void *)) { struct json_object **result; diff --git a/json_object.h b/json_object.h index d67f384..06c0349 100644 --- a/json_object.h +++ b/json_object.h @@ -556,7 +556,7 @@ JSON_EXPORT size_t json_object_array_length(const struct json_object *obj); * @param sort_fn a sorting function */ JSON_EXPORT void json_object_array_sort(struct json_object *jso, - int (*sort_fn)(const void *, const void *)); + int(__cdecl *sort_fn)(const void *, const void *)); /** Binary search a sorted array for a specified key object. * @@ -574,7 +574,7 @@ JSON_EXPORT void json_object_array_sort(struct json_object *jso, */ JSON_EXPORT struct json_object * json_object_array_bsearch(const struct json_object *key, const struct json_object *jso, - int (*sort_fn)(const void *, const void *)); + int(__cdecl *sort_fn)(const void *, const void *)); /** Add an element to the end of a json_object of type json_type_array * diff --git a/strerror_override.c b/strerror_override.c index a3dd377..694f816 100644 --- a/strerror_override.c +++ b/strerror_override.c @@ -60,7 +60,7 @@ static struct // Enabled during tests static int _json_c_strerror_enable = 0; -extern char *getenv(const char *name); // Avoid including stdlib.h +extern char * __cdecl getenv(const char *name); // Avoid including stdlib.h #define PREFIX "ERRNO=" static char errno_buf[128] = PREFIX;