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]

Re: using C++ STL containers in GCC/gfortran source code

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.


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