This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[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
easiest one.
I've made the change in three places in cp/classes.c; the patch can be
found here:


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?

 Pedro Lamarão

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]