This is the mail archive of the
mailing list for the GCC project.
[gcc-in-cxx] replacing qsort with std::sort
- From: Pedro Lamarão <pedro dot lamarao at ccppbrasil dot org>
- To: gcc at gcc dot gnu dot org
- Date: Tue, 11 Aug 2009 21:03:45 -0300
- Subject: [gcc-in-cxx] replacing qsort with std::sort
I've recently started my contributions to the gcc-in-cxx project, and
eventually decided on the qsort suggestion because it seems the
I've made the change in three places in cp/classes.c; the patch can be
Is this the way to go?
Some questions occurred to me: in order to support a C and a C++
compiler at the same time, what "portability" mechanism should be
used? #ifdef guards to switch between qsort and std::sort on the spot,
based on __cplusplus? Should a helper function be declared somewhere?
Also, std::sort requires a "less" function on reference-tovalue-type,
so the current foo_cmp functions can't be reused.
Would a separate patch to introduce foo_less variants be acceptable
for GCC 4.5 right now?
Also, is the gcc-in-cxx branch still active? Should my objective be to
contribute patches to this branch?
On a side note, I've studied vec.h and found it hard to change.
One reason is because this header is included by the gen*.c stuff,
which is still being compiled by a C compiler, even when building with
a C++ compiler is enabled.
I've considered providing a separate version of vec.h when C++ is
being used, to avoid infinite #ifdefs.
Is this a good idea?