This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
using C++ STL containers in GCC/gfortran source code
- From: Janus Weil <janus at gcc dot gnu dot org>
- To: gcc mailing list <gcc at gcc dot gnu dot org>, gfortran <fortran at gcc dot gnu dot org>, Jakub Jelinek <jakub at redhat dot com>
- Date: Fri, 16 Dec 2016 16:41:47 +0100
- Subject: using C++ STL containers in GCC/gfortran source code
- Authentication-results: sourceware.org; auth=none
Hi all,
I recently ran into some discussion with Jakub about using std::string
in gfortran (see PR 78822), which got me curious about some general
points ...
What I'd like to know is: In the current state of things in GCC, is it
possible/reasonable to use any of the STL containers (like
std::vector, std::string, whatever) in GCC and its front ends (in
particular gfortran)?
That question has two parts:
1) Is it technically possible at all? Are there drawbacks/pitfalls?
(In particular Jakub mentioned possible memory management issues, i.e.
xmalloc vs malloc etc.)
2) If technically possible, is it encouraged? I didn't find any
statement about STL in the GCC coding conventions
(https://gcc.gnu.org/codingconventions.html).
Looking through the current GCC code base, it seems that mostly the Go
FE is making extensive use of the things like std::string and
std::vector, while other parts only use such things rarely.
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. Would there be a general problem with using
std::string in gfortran?
Cheers,
Janus