This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: using C++ STL containers in GCC/gfortran source code
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Janus Weil <janus at gcc dot gnu dot org>
- Cc: gcc mailing list <gcc at gcc dot gnu dot org>, gfortran <fortran at gcc dot gnu dot org>
- Date: Fri, 16 Dec 2016 19:04:15 +0100
- Subject: Re: using C++ STL containers in GCC/gfortran source code
- Authentication-results: sourceware.org; auth=none
- References: <CAKwh3qgUN=mTFPg6Ew6Yk9RXgS3CttE7O3cGMQRcLKNqUOjBng@mail.gmail.com> <CAKwh3qii7EFG4VECNOgqF6kXczvwK0jQbQyDcQTnwuzSdSCfRw@mail.gmail.com>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Fri, Dec 16, 2016 at 06:55:12PM +0100, Janus Weil wrote:
> To get to more specific questions ...
>
> > Basically the only STL construct used in the Fortran FE right now
> > seems to be std::swap, and a single instance of std::map in
> > trans-common.c.
>
> I see that fortran/trans-common.c has:
>
> #define INCLUDE_MAP
>
> and apparently there is also a INCLUDE_STRING macro. I guess if I want
> to use std::string I don't #include <string>, but #define
> INCLUDE_STRING, right? Why are those macros needed, exactly?
They are needed because system.h poisons lots of things, including malloc
etc. So including system headers after system.h is problematic.
That said, using std::string for what you talk in the PR would make it
impossible to translate it, if you build a sentence as:
ss << "Argument " << something () << " and '" << something_else () << "'";
then our framework can't deal with that, translating portions of a sentence
is not going to be useful for many languages.
Using *printf or similar formatting strings allows the translator to see
the whole sentence with arguments, and e.g. when needed can swap
some arguments using %4$s syntax etc.
Jakub