This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
types for the job - a question of style
- From: THOMAS Paul Richard <prthomas at drfccad dot cea dot fr>
- To: 'Tobias Schlüter' <tobias dot schlueter at physik dot uni-muenchen dot de>, "'sgk at troutmask dot apl dot washington dot edu'" <sgk at troutmask dot apl dot washington dot edu>
- Cc: "'fortran at gcc dot gnu dot org'" <fortran at gcc dot gnu dot org>
- Date: Tue, 12 Apr 2005 09:18:37 +0200
- Subject: types for the job - a question of style
Since the rush for 4.0 is off and triggered by Tobi's recommendation to use
size_t for character indices, I have done what I had meant to do a while
back and re-examined all the types in use in the namelist modifications.
Tailoring types to the jobs works fine but I am left wondering if it is
acceptable/efficient/portable. Examples are:
1] using uint8_t for rank and loop counters over dimensions. The fortran 9x
and fortran 2kx standards limit rank to 7 so unit8_t is more than enough;
2] again uint8_t for the length, in bytes, of intrinsic types. 255bytes is
enough, isn't it?
3] int8_t for flags, where values are typically -1, 0 or 1;
4] ssize_t for indices that can go -ve (Note that one does find ssize_t
meaning short size_t rather than gcc's signed size_t.); and
5] uint8_t / int8_t in general, where the range is always going to be
sufficient.
The main reason for doing this are the, admitedly small, savings in memory.
Does the C compiler pack these types during the gcc build or are they
aligned on boundaries such that this is a pointless exercise?
Regards
Paul