dnl This defines PACKAGE and VERSION.
AM_INIT_AUTOMAKE([gnu 1.8 dist-bzip2])
-dnl GiNaC archive file version information.
-dnl
-dnl If properties have been added, ARCHIVE_VERSION += 1, ARCHIVE_AGE += 1.
-dnl If backwards compatibility has been broken, set ARCHIVE_AGE to 0.
-dnl
-dnl The version number in newly created archives will be ARCHIVE_VERSION.
-dnl Archives version (ARCHIVE_VERSION-ARCHIVE_AGE) thru ARCHIVE_VERSION can
-dnl be read by this version of the GiNaC library.
-
-ARCHIVE_VERSION=3
-ARCHIVE_AGE=3
-
-AC_SUBST(ARCHIVE_VERSION)
-AC_SUBST(ARCHIVE_AGE)
-AC_DEFINE_UNQUOTED(ARCHIVE_VERSION, $ARCHIVE_VERSION, [Current GiNaC archive file version number])
-AC_DEFINE_UNQUOTED(ARCHIVE_AGE, $ARCHIVE_AGE, [GiNaC archive file version age])
-
dnl libtool versioning
LT_VERSION_INFO="ginac_lt_current:ginac_lt_revision:ginac_lt_age"
AC_SUBST(LT_VERSION_INFO)
#include "config.h"
#endif
#include "tostring.h"
+#include "version.h"
#include <iostream>
#include <stdexcept>
os.put('A');
os.put('R');
os.put('C');
- write_unsigned(os, ARCHIVE_VERSION);
+ write_unsigned(os, GINACLIB_ARCHIVE_VERSION);
// Write atoms
unsigned num_atoms = ar.atoms.size();
is.get(c1); is.get(c2); is.get(c3); is.get(c4);
if (c1 != 'G' || c2 != 'A' || c3 != 'R' || c4 != 'C')
throw (std::runtime_error("not a GiNaC archive (signature not found)"));
+ static const unsigned max_version = GINACLIB_ARCHIVE_VERSION;
+ static const unsigned min_version = GINACLIB_ARCHIVE_VERSION - GINACLIB_ARCHIVE_AGE;
unsigned version = read_unsigned(is);
- if (version > ARCHIVE_VERSION || version < ARCHIVE_VERSION - ARCHIVE_AGE)
- throw (std::runtime_error("archive version " + ToString(version) + " cannot be read by this GiNaC library (which supports versions " + ToString(ARCHIVE_VERSION-ARCHIVE_AGE) + " thru " + ToString(ARCHIVE_VERSION)));
+ if ((version > max_version) || (version < min_version))
+ throw (std::runtime_error("archive version " + ToString(version) + " cannot be read by this GiNaC library (which supports versions " + ToString(min_version) + " thru " + ToString(max_version)));
// Read atoms
unsigned num_atoms = read_unsigned(is);
/* Micro version of GiNaC */
#define GINACLIB_MICRO_VERSION 2
+/*
+ * GiNaC archive file version information.
+ *
+ * The current archive version is GINACLIB_ARCHIVE_VERSION. This is
+ * the version of archives created by the current version of GiNaC.
+ * Archives version (GINACLIB_ARCHIVE_VERSION - GINACLIB_ARCHIVE_AGE)
+ * thru * GINACLIB_ARCHIVE_VERSION can be read by current version
+ * of GiNaC.
+ *
+ * Backward compatibility notes:
+ * If new properties have been added:
+ * GINACLIB_ARCHIVE_VERSION += 1
+ * GINACLIB_ARCHIVE_AGE += 1
+ * If backwards compatibility has been broken, i.e. some properties
+ * has been removed, or their type and/or meaning changed:
+ * GINACLIB_ARCHIVE_VERSION += 1
+ * GINACLIB_ARCHIVE_AGE = 0
+ */
+#define GINACLIB_ARCHIVE_VERSION 3
+#define GINACLIB_ARCHIVE_AGE 3
+
namespace GiNaC {
extern const int version_major;