Menu

#122 Compiling against CFITSIO 4.0.x fails as CFITSIO now uses a 3-field version numbering format

v3.80+
closed-fixed
nobody
None
5
2022-05-27
2021-08-18
Atri
No

CFITSIO switched to a 3-field version numbering format with version 4.0.0 [1] breaking healpix builds.

[   37s] In file included from cxxsupport/fitshandle.cc:36:
[   37s] /usr/include/cfitsio/fitsio.h:37:25: error: too many decimal points in number
[   37s]    37 | #define CFITSIO_VERSION 4.0.0
[   37s]       |                         ^~~~~
[   37s] cxxsupport/fitshandle.cc:802:42: note: in expansion of macro 'CFITSIO_VERSION'
[   37s]   802 |       int v_header  = nearest<int>(1000.*CFITSIO_VERSION),
[   37s]       |                                          ^~~~~~~~~~~~~~~
[   37s] cxxsupport/fitshandle.cc: In constructor '{anonymous}::cfitsio_checker::cfitsio_checker()':
[   37s] cxxsupport/fitshandle.cc:804:21: error: 'v_library' was not declared in this scope
[   37s]   804 |       if (v_header!=v_library)
[   37s]       |                     ^~~~~~~~~

[1] https://heasarc.gsfc.nasa.gov/FTP/software/fitsio/c/docs/changes.txt

Related

Bugs: #122

Discussion

  • Atri

    Atri - 2021-08-18

    Something like this patch seems to work:

    Index: healpix-3.80/src/cxx/cxxsupport/fitshandle.cc
    ===================================================================
    --- healpix-3.80.orig/src/cxx/cxxsupport/fitshandle.cc
    +++ healpix-3.80/src/cxx/cxxsupport/fitshandle.cc
    @@ -799,12 +799,27 @@ class cfitsio_checker
           float fitsversion;
           planck_assert(fits_get_version(&fitsversion),
             "error calling fits_get_version()");
    
    +      /* CFITSIO 4.x switched to a three version format (4.0.0), as opposed
    +       * to previous two-number versions (3.47). Version 4 defines a new macro
    +       * CFITSIO_MICRO to track the patch level in the version. We check if
    +       * macro is defined, and fall back to the old behaviour if it is not.
    +       * If it is, we adapt to the new value returned by 'fits_get_version'.
    +       */
    +#ifdef CFITSIO_MICRO
    +      int v_header  = nearest<int>(1E6*CFITSIO_MAJOR + 1000.*CFITSIO_MINOR + CFITSIO_MICRO),
    +          v_library = nearest<int>(1E6*fitsversion);
    +      if (v_header!=v_library)
    +        cerr << endl << "WARNING: version mismatch between CFITSIO header (v"
    +             << dataToString(v_header*1.0E-6) << ") and linked library (v"
    +             << dataToString(v_library*1.0E-6) << ")." << endl << endl;
    +#else
           int v_header  = nearest<int>(1000.*CFITSIO_VERSION),
               v_library = nearest<int>(1000.*fitsversion);
           if (v_header!=v_library)
             cerr << endl << "WARNING: version mismatch between CFITSIO header (v"
                  << dataToString(v_header*0.001) << ") and linked library (v"
                  << dataToString(v_library*0.001) << ")." << endl << endl;
    +#endif
           }
       };
    
     
  • Martin Reinecke

    Martin Reinecke - 2021-08-18

    Thanks a lot for the report and the patch! I'll integrate this as soon as possible.

     
  • Martin Reinecke

    Martin Reinecke - 2021-08-18

    Should be fixed on trunk now. Thanks again!

     
  • Anonymous

    Anonymous - 2021-10-19

    I have no idea how, but the patch was not properly applied. Fixing this now.

     
  • Anonymous

    Anonymous - 2021-11-17

    I walked into the same issue today, my solutoin (after confirming with the cfitsio developers how fits_get_version will behave in the future is simpler:

    +      #if CFITSIO_MAJOR >= 4
    +      float fitsversion_header = CFITSIO_MAJOR + 0.01 * CFITSIO_MINOR + 0.0001 * CFITSIO_MICRO;
    +      #else
    +      float fitsversion_header = CFITSIO_VERSION;
    +      #endif
    +      int v_header  = nearest<int>(1000.*fitsversion_header);
    

    This is the answer I received from the cfitsio maintainers:

    This issue was pointed out to us shortly after version 4.0.0 was released, and so we've updated fits_get_version for future releases. Going forward it will still return a float for backwards compatibility, but the value will be calculated as: major_number + .01minor_number + .0001micro_number. This of course limits the number of minor and micro version increments to 100, but we don't anticipate that being a problem.

     
  • Eric Hivon

    Eric Hivon - 2022-01-27

    fixed in v3.81

     
  • Eric Hivon

    Eric Hivon - 2022-01-27
    • status: open --> closed-fixed
     
  • Reijo Keskitalo

    Reijo Keskitalo - 2022-03-29

    The patch submitted by Atri worked fine with cfitsio 4.00 but fails with 4.01. Looks like the cfitsio developers use 2 rather than 3 digits for the version fields.

    Fix is to use the code submitted by Anonymous on 2021-11-17 or use this modified version of the patch: https://github.com/hpc4cmb/libconviqt/blob/master/levels/cxxsupport/fitshandle.cc#L814-L828.
    Personally, I prefer comparing integers rather than floats.

     
  • Martin Reinecke

    Martin Reinecke - 2022-03-30

    Thanks! I applied the fix on the trunk.

    Eric, should I update the 3.81 branch too?

    If anyone could double-check that everything works, that would be great.

     
    • Eric Hivon

      Eric Hivon - 2022-04-04

      Hi Martin,

      On 30/03/2022 10:43, Martin Reinecke wrote:

      Thanks! I applied the fix on the trunk.

      Eric, should I update the 3.81 branch too?

      yes, go ahead.

      Eric

      If anyone could double-check that everything works, that would be great.


      [bugs:#122] https://sourceforge.net/p/healpix/bugs/122/ Compiling
      against CFITSIO 4.0.x fails as CFITSIO now uses a 3-field version
      numbering format

      Status: closed-fixed
      Group: v3.80+
      Created: Wed Aug 18, 2021 02:25 AM UTC by Atri
      Last Updated: Tue Mar 29, 2022 04:21 PM UTC
      Owner: nobody

      CFITSIO switched to a 3-field version numbering format with version
      4.0.0 [1] breaking healpix builds.

      |[ 37s] In file included from cxxsupport/fitshandle.cc:36: [ 37s]
      /usr/include/cfitsio/fitsio.h:37:25: error: too many decimal points in
      number [ 37s] 37 | #define CFITSIO_VERSION 4.0.0 [ 37s] | ^~~~~ [ 37s]
      cxxsupport/fitshandle.cc:802:42: note: in expansion of macro
      'CFITSIO_VERSION' [ 37s] 802 | int v_header =
      nearest<int>(1000.*CFITSIO_VERSION), [ 37s] | ^~~~~~~~~~~~~~~ [ 37s]
      cxxsupport/fitshandle.cc: In constructor
      '{anonymous}::cfitsio_checker::cfitsio_checker()': [ 37s]
      cxxsupport/fitshandle.cc:804:21: error: 'v_library' was not declared
      in this scope [ 37s] 804 | if (v_header!=v_library) [ 37s] | ^~~~~~~~~ |</int>

      [1] https://heasarc.gsfc.nasa.gov/FTP/software/fitsio/c/docs/changes.txt


      Sent from sourceforge.net because you indicated interest in
      https://sourceforge.net/p/healpix/bugs/122/

      To unsubscribe from further messages, please visit
      https://sourceforge.net/auth/subscriptions/

       

      Related

      Bugs: #122

  • Anonymous

    Anonymous - 2022-05-27

    This error also occur in my compilation. When I run the program, a warning will print, says that header versio not matched, so I tracked this error then I found the bug, in fact in cfitsio.4.1.0, the version was calculated in format: MAJOR + 0.01xMINOR + 0.0001xMICRO, so the right header version should be 1E6MAJOR + 1E4MINOR+1E2*MICRO.

     

Anonymous
Anonymous

Add attachments
Cancel





MongoDB Logo MongoDB