Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

qsort callback should always use cdecl calling convention #80

Merged
merged 1 commit into from
Feb 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading