Skip to content

Commit

Permalink
qsort callback should always use cdecl calling convention
Browse files Browse the repository at this point in the history
  • Loading branch information
GabeNI authored and cxong committed Feb 27, 2024
1 parent 782fb12 commit a4a2db5
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions tinydir.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,16 @@ extern "C" {
# define _TINYDIR_FUNC static
#endif

#if defined(i386) || defined(__i386__) || defined(__i386) || defined(_M_IX86)
#ifdef _MSC_VER
# define _TINYDIR_CDECL __cdecl
#else
# define _TINYDIR_CDECL __attribute__((cdecl))
#endif
#else
# define _TINYDIR_CDECL
#endif

/* readdir_r usage; define TINYDIR_USE_READDIR_R to use it (if supported) */
#ifdef TINYDIR_USE_READDIR_R

Expand Down Expand Up @@ -255,7 +265,7 @@ int tinydir_file_open(tinydir_file *file, const _tinydir_char_t *path);
_TINYDIR_FUNC
void _tinydir_get_ext(tinydir_file *file);
_TINYDIR_FUNC
int _tinydir_file_cmp(const void *a, const void *b);
int _TINYDIR_CDECL _tinydir_file_cmp(const void *a, const void *b);
#ifndef _MSC_VER
#ifndef _TINYDIR_USE_READDIR
_TINYDIR_FUNC
Expand Down Expand Up @@ -775,7 +785,7 @@ void _tinydir_get_ext(tinydir_file *file)
}

_TINYDIR_FUNC
int _tinydir_file_cmp(const void *a, const void *b)
int _TINYDIR_CDECL _tinydir_file_cmp(const void *a, const void *b)
{
const tinydir_file *fa = (const tinydir_file *)a;
const tinydir_file *fb = (const tinydir_file *)b;
Expand Down

0 comments on commit a4a2db5

Please sign in to comment.