Skip to content

Commit

Permalink
Avoid redundant declarations for wxQsort()
Browse files Browse the repository at this point in the history
This works around gcc -Wredundant-decls warning that was given (if
explicitly enabled) when both wx/vector.h and wx/utils.h were included.

The workaround is ugly, but it doesn't seem worth it to introduce a
separate wx/qsort.h header just for this single function, which seems to
be the only other way to fix this.

Closes #1271
  • Loading branch information
vadz committed Mar 21, 2019
1 parent f5f912e commit 3938084
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
7 changes: 7 additions & 0 deletions include/wx/utils.h
Expand Up @@ -603,6 +603,11 @@ WXDLLIMPEXP_BASE bool wxGetDiskSpace(const wxString& path,






// See wx/vector.h for more about this hack.
#ifndef wxQSORT_DECLARED

#define wxQSORT_DECLARED

typedef int (*wxSortCallback)(const void* pItem1, typedef int (*wxSortCallback)(const void* pItem1,
const void* pItem2, const void* pItem2,
const void* user_data); const void* user_data);
Expand All @@ -612,6 +617,8 @@ WXDLLIMPEXP_BASE void wxQsort(void* pbase, size_t total_elems,
size_t size, wxSortCallback cmp, size_t size, wxSortCallback cmp,
const void* user_data); const void* user_data);


#endif // !wxQSORT_DECLARED



#if wxUSE_GUI // GUI only things from now on #if wxUSE_GUI // GUI only things from now on


Expand Down
9 changes: 9 additions & 0 deletions include/wx/vector.h
Expand Up @@ -41,13 +41,22 @@ inline void wxVectorSort(wxVector<T>& v)


// wxQsort is declared in wx/utils.h, but can't include that file here, // wxQsort is declared in wx/utils.h, but can't include that file here,
// it indirectly includes this file. Just lovely... // it indirectly includes this file. Just lovely...
//
// Moreover, just declaring it here unconditionally results in gcc
// -Wredundant-decls warning, so use a preprocessor guard to avoid this.
#ifndef wxQSORT_DECLARED

#define wxQSORT_DECLARED

typedef int (*wxSortCallback)(const void* pItem1, typedef int (*wxSortCallback)(const void* pItem1,
const void* pItem2, const void* pItem2,
const void* user_data); const void* user_data);
WXDLLIMPEXP_BASE void wxQsort(void* pbase, size_t total_elems, WXDLLIMPEXP_BASE void wxQsort(void* pbase, size_t total_elems,
size_t size, wxSortCallback cmp, size_t size, wxSortCallback cmp,
const void* user_data); const void* user_data);


#endif // !wxQSORT_DECLARED

namespace wxPrivate namespace wxPrivate
{ {


Expand Down

0 comments on commit 3938084

Please sign in to comment.