This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Switching to C++ by default in 4.8
On Wed, Apr 4, 2012 at 8:04 PM, Richard Guenther
<richard.guenther@gmail.com> wrote:
>
> I agree for the idea of converting all of GCC to C++ (whatever that means).
> I disagree for the part making the internal infrastructure easier to use,
> understand and maintain. ÂWhich means targeting mostly isolated sub-systems,
> like vec.h (and other various containers), double-int.[ch] (and other various
> way of representing and working with constants). ÂMaking tree or gimple a
> C++ class with inheritance and whatever is indeed a huge waste of time
> and existing developer ressources (that, if only because they have to adapt
> and maintain two completely different code-bases over some time).
>
> I expect the GCC core to maintain written in C, compiled by C++.
>
Making tree or gimple or even rtl a C++ class with inheritance should be easy.
Current functions and accessor macros can be preserved.
for example:
C:
typedef struct base_type_tag {
int m_data_1;
} base_type;
typedef struct derived_type_tag {
struct base_type base;
int m_data_2;
} derived_type;
#define BASE_TYPE_ACCESSOR_MACRO_1(a) ...
#define DERIVED_TYPE_ACCESSOR_MACRO_2(a) ...
int base_type _func_1(base_type * p_base, ...)
{
}
int derived_type_func_2(derived_type * p_derived, ...)
{
}
C++:
class base_type {
int m_data_1;
getter_1();
setter_1();
method_1();
};
class derived_type : public base_type {
int m_data_2;
getter_2();
setter_2();
method_2();
};
#define BASE_TYPE_ACCESSOR_MACRO_1(a) ...
#define DERIVED_TYPE_ACCESSOR_MACRO_2(a) ...
int base_type _func_1(base_type * p_base, ...)
{
}
int derived_type_func_2(derived_type * p_derived, ...)
{
}
base_type::getter_1()
{
}
base_type::setter_1()
{
}
base_type::method_1()
{
}
derived_type::getter_2()
{
}
derived_type::setter_2()
{
}
derived_type::method_2()
{
}
--
Chiheng Xu