Replace _Bool with bool in C interface headers for C++ compatibility#42
Open
luca-heltai wants to merge 1 commit into
Open
Replace _Bool with bool in C interface headers for C++ compatibility#42luca-heltai wants to merge 1 commit into
luca-heltai wants to merge 1 commit into
Conversation
_Bool is a C11 keyword that is not recognized by C++ compilers, causing build failures when PSBLAS headers are included from C++. The headers already include <stdbool.h> (via psb_c_base.h) which defines bool as a portable alias, so use bool instead of _Bool. This fixes errors like: error: unknown type name '_Bool' in psb_c_dsprn(), psb_c_ssprn(), psb_c_csprn(), psb_c_zsprn().
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The C interface headers
psb_c_dbase.h,psb_c_sbase.h,psb_c_cbase.h, andpsb_c_zbase.huse_Bool(a C11 keyword) in the*sprnfunction declarations.When these headers are included from C++ code (via
extern "C"), the C++ compiler fails with:This is a known portability issue —
_Boolis C-only and not recognized by C++ compilers, even though the headers are designed to be included from both C and C++ (they already use#ifdef __cplusplus / extern "C" {).Fix
Replace
_Boolwithbool(from<stdbool.h>), which is already included viapsb_c_base.h. This type works correctly in both C (whereboolis atypedeffor_Bool) and C++ (whereboolis a native type).Files changed
cbind/base/psb_c_dbase.h—psb_c_dsprn()cbind/base/psb_c_sbase.h—psb_c_ssprn()cbind/base/psb_c_cbase.h—psb_c_csprn()cbind/base/psb_c_zbase.h—psb_c_zsprn()This change has no effect on the ABI since
booland_Boolare both mapped tointin the C/ABI calling convention (via Fortranbind(c)withlogical).