This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran 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: Predefined Macros



Le 13 avr. 07 à 20:01, Brooks Moses a écrit :


Steve Kargl wrote:
#define __GFORTRAN__  20070411
or #define __GFORTRAN__ 1
#define __GFORTRAN_MAJOR__ 4
#define __GFORTRAN_MINOR__ 3

I think I prefer the latter; the relevant distinctions between the variants of 4.3 (especially the released versions) are likely to be less important than the distinctions between the various branches that would have the same compilation date.

So do I. __GFORTRAN__ is nice. But I think having MAJOR and MINOR version macros is redundant with __GNUC__, __GNUC_MINOR__ and __GNUC_PATCHLEVEL__. And redundant information is bad!



If defining the relevant standard is useful, perhaps add

#define __GFORTRAN_STANDARD__ f95

(or "gnu", or "f2003", or whatever.)

Standard is nice, but it should be an integer because it makes ordered comparisons possible: "#if __GFORTRAN_STANDARD__ >= 2003"
So, I think the macro should be defined to the latest standard year number accepted (2003 for legacy, gnu and f2003; 1995 for f95).


FX


PS: a tentative patch (not tested yet) for defining __GFORTRAN__:


Index: gcc/c-cppbuiltin.c
===================================================================
--- gcc/c-cppbuiltin.c (revision 123388)
+++ gcc/c-cppbuiltin.c (working copy)
@@ -569,6 +569,9 @@
if (flag_openmp)
cpp_define (pfile, "_OPENMP=200505");
+ if (lang_fortran)
+ cpp_define (pfile, "__GFORTRAN__=1");
+
builtin_define_type_sizeof ("__SIZEOF_INT__", integer_type_node);
builtin_define_type_sizeof ("__SIZEOF_LONG__", long_integer_type_node);
builtin_define_type_sizeof ("__SIZEOF_LONG_LONG__",
Index: gcc/c-opts.c
===================================================================
--- gcc/c-opts.c (revision 123388)
+++ gcc/c-opts.c (working copy)
@@ -73,7 +73,7 @@
static bool verbose;
/* If -lang-fortran seen. */
-static bool lang_fortran = false;
+bool lang_fortran = false;
/* Dependency output file. */
static const char *deps_file;
Index: gcc/c-common.h
===================================================================
--- gcc/c-common.h (revision 123388)
+++ gcc/c-common.h (working copy)
@@ -254,6 +254,9 @@
#define c_dialect_cxx() (c_language & clk_cxx)
#define c_dialect_objc() (c_language & clk_objc)
+/* FXC */
+extern bool lang_fortran;
+
/* Information about a statement tree. */
struct stmt_tree_s GTY(()) {



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