Skip to content

Commit

Permalink
Replace #define complex by optional typedef
Browse files Browse the repository at this point in the history
The macro #define complex broke code that used complex.
The typedef is only provided, when enbaled with the CMake
option enable_compatibility_complex.
  • Loading branch information
gruenich committed Jul 23, 2024
1 parent 6f7ea89 commit 547c316
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ option(enable_doc "Add target 'doc' to build Doxygen documentation" OFF)
option(enable_examples "Build examples" ON)
option(enable_fortran "Build Fortran interface" ${enable_fortran_xSDK})
option(enable_tests "Build tests" ON)
option(enable_compatibility_complex "Provide typdef 'complex' for compatibility with older SuperLU version" OFF)

include(CTest)
include(GNUInstallDirs)
Expand Down Expand Up @@ -100,6 +101,11 @@ endif()
set(SUPERLU_VERSION "${PROJECT_VERSION}")
set(SUPERLU_REV "${PROJECT_REV}")

if(enable_compatibility_complex)
add_compile_definitions(SUPERLU_TYPEDEF_COMPLEX)
endif()


#-- BLAS
option(TPL_ENABLE_INTERNAL_BLASLIB "Build the CBLAS library" ${enable_internal_blaslib})
option(TPL_BLAS_LIBRARIES "List of absolute paths to blas libraries [].")
Expand Down
6 changes: 5 additions & 1 deletion SRC/slu_scomplex.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ at the top-level directory.

typedef struct { float r, i; } singlecomplex;

#define complex singlecomplex // backward compatibility
#if defined(SUPERLU_TYPEDEF_COMPLEX) || DOXYGEN
//! \brief backward compatibility with older versions of SuperLU
//! Add -D enable_compatibility_complex=ON to your CMake call
typedef singlecomplex complex;
#endif

/* Macro definitions */

Expand Down

0 comments on commit 547c316

Please sign in to comment.