Skip to content

Fortran: simplify H5config_f.inc.cmake to use #cmakedefine directly#6423

Merged
brtnfld merged 1 commit into
HDFGroup:developfrom
brtnfld:fix-fortran-config-ifdef-macro
Jun 2, 2026
Merged

Fortran: simplify H5config_f.inc.cmake to use #cmakedefine directly#6423
brtnfld merged 1 commit into
HDFGroup:developfrom
brtnfld:fix-fortran-config-ifdef-macro

Conversation

@brtnfld

@brtnfld brtnfld commented May 29, 2026

Copy link
Copy Markdown
Collaborator

All #cmakedefine01 CMAKE_H5_* blocks used a five-line pattern:

      #cmakedefine01 CMAKE_H5_HAVE_FOO
      #if CMAKE_H5_HAVE_FOO == 0
      #undef H5_HAVE_FOO
      #else
      #define H5_HAVE_FOO
      #endif

Replace all such blocks with #cmakedefine H5_HAVE_FOO, using the H5_*
variable directly. MPI_LOGICAL_KIND retains its value via
#cmakedefine H5_MPI_LOGICAL_KIND @H5_MPI_LOGICAL_KIND@.

This also fixes #6419: H5_FORTRAN_C_BOOL_IS_UNIQUE was emitted as
#define H5_FORTRAN_C_BOOL_IS_UNIQUE 0 when C_BOOL and default LOGICAL
are the same kind (e.g. Apple PowerPC ABI). #ifdef only tests whether
a macro is defined, not its value, so the guard in H5_test_buildiface.F90
was always true and verify_c_bool was written into tf_gen.F90 regardless,
causing an "Ambiguous interfaces" build failure on that platform.

@brtnfld brtnfld requested review from derobins and epourmal as code owners May 29, 2026 21:24
@github-project-automation github-project-automation Bot moved this to To be triaged in HDF5 - TRIAGE & TRACK May 29, 2026
@brtnfld brtnfld requested review from jhendersonHDF and lrknox and removed request for derobins and epourmal May 29, 2026 21:25
hyoklee
hyoklee previously approved these changes May 29, 2026
@brtnfld brtnfld force-pushed the fix-fortran-config-ifdef-macro branch 4 times, most recently from b0dfb45 to a6f1ecb Compare May 29, 2026 21:58
@brtnfld brtnfld changed the title Fortran: fix #ifdef vs #if for 0/1 preprocessor macros in H5config_f.inc Fortran: simplify H5config_f.inc.cmake to use #cmakedefine directly May 29, 2026
@barracuda156

Copy link
Copy Markdown

@brtnfld Thank you for tracking down the problem!

@barracuda156 barracuda156 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The patch fixes the build on powerpc-apple-darwin.

@brtnfld brtnfld force-pushed the fix-fortran-config-ifdef-macro branch from a6f1ecb to c5c1b68 Compare June 1, 2026 14:13
@brtnfld brtnfld force-pushed the fix-fortran-config-ifdef-macro branch 2 times, most recently from 936f9bb to b1293fd Compare June 1, 2026 14:19
@barracuda156

Copy link
Copy Markdown

@brtnfld Do I need to rebuild with updated patch or the outcome is identical?

@brtnfld brtnfld force-pushed the fix-fortran-config-ifdef-macro branch from b1293fd to 468e828 Compare June 1, 2026 14:31
All #cmakedefine01 CMAKE_H5_* blocks used a five-line pattern:

  #cmakedefine01 CMAKE_H5_HAVE_FOO
  #if CMAKE_H5_HAVE_FOO == 0
  #undef H5_HAVE_FOO
  #else
  #define H5_HAVE_FOO
  #endif

This is exactly what #cmakedefine H5_HAVE_FOO does: it emits
#define H5_HAVE_FOO (no value) when the CMake variable is truthy and
/* #undef H5_HAVE_FOO */ when falsy.  The CMAKE_H5_* intermediate
variables in fortran/src/CMakeLists.txt were only needed to feed these
blocks and are no longer required.

Replace all such blocks with #cmakedefine H5_HAVE_FOO, using the H5_*
variable directly.  MPI_LOGICAL_KIND retains its value via
#cmakedefine H5_MPI_LOGICAL_KIND @H5_MPI_LOGICAL_KIND@.

This also fixes a real bug: H5_FORTRAN_C_BOOL_IS_UNIQUE was emitted as
#define H5_FORTRAN_C_BOOL_IS_UNIQUE 0 when C_BOOL and default LOGICAL
are the same kind (e.g. Apple PowerPC ABI).  #ifdef only tests whether
a macro is defined, not its value, so the guard in H5_test_buildiface.F90
was always true and verify_c_bool was written into tf_gen.F90 regardless,
causing an "Ambiguous interfaces" build failure on that platform.
@brtnfld brtnfld force-pushed the fix-fortran-config-ifdef-macro branch from 468e828 to 5b044ac Compare June 1, 2026 14:37
@brtnfld

brtnfld commented Jun 1, 2026

Copy link
Copy Markdown
Collaborator Author

@barracuda156, up to you, I was converting some non-related to H5_FORTRAN_C_BOOL_IS_UNIQUE cases to make them all consistent. It might be good to check once it passes, since we don't test on that particular hardware. I should be done with the updates.

@brtnfld

brtnfld commented Jun 1, 2026

Copy link
Copy Markdown
Collaborator Author

@barracuda156, all good? It is ready to be merged.

@barracuda156

Copy link
Copy Markdown

all good? It is ready to be merged.

I will rebuild now.

@brtnfld brtnfld assigned brtnfld and unassigned lrknox and jhendersonHDF Jun 1, 2026
@barracuda156

Copy link
Copy Markdown

@brtnfld Yes, all good.

@brtnfld brtnfld merged commit e4c16e9 into HDFGroup:develop Jun 2, 2026
246 of 247 checks passed
@github-project-automation github-project-automation Bot moved this from To be triaged to Done in HDF5 - TRIAGE & TRACK Jun 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Build failure of v. 2.1.1 with gcc-14: Error: Ambiguous interfaces in generic interface 'verify' for 'verify_logical' at (1) and 'verify_c_bool' at (2)

5 participants