Comments (9)
I like the char
option. It seems the easiest solution. What do you think @goulart-paul ?
from qdldl.
The only purpose of the above is to ensure that the QDLDL_bool
we define will make sense to the C compiler, which will not be the case if we have a C89 only compiler and we ask for _Bool
.
It might be better to check for compiler support of '_Bool' in cmake directly before building qdldl, using something like https://cmake.org/cmake/help/v3.0/module/CheckCSourceCompiles.html
The process in cmake could be:
-
Include a small check in cmake to see if test code with a
_Bool
compiles. -
Define QDLDL_BOOL_TYPE accordingly within cmake, taking it as either
int
or_Bool
depending on the outcome of step 1. -
Put
typedef @QDLDL_BOOL_TYPE@ QDLDL_bool;
intoqdldl_types.h.in
as a single line instead of switching on__STDC_VERSION__
as above.
In this way the header would be unambiguous about the logical type we use and we would be sure that the header is consistent with what we actually built.
If the above seems like it would fix the problem with C++ compatibility I can try it.
from qdldl.
From what I can tell, _Bool
will not work for C++. It's not defined in the C++ standard or supported by the C++ compilers that I tried. I also tried using bool
and including stdbool.h
but that didn't work either on the C++ side.
from qdldl.
Another option would be to just make it an enum
, e.g.
typedef enum _QDLDL_bool { false, true } QDLDL_bool;
That ends up as the same size as int
I think, which is not quite as compact as it could be but better than nothing. The only point of any of this was to avoid it being long long
when we define QDLDL_int
that way.
from qdldl.
enum
s are also a bit problematic to use at library boundaries because their size is not defined in the standard. If you compile qdldl into a shared library with compiler 1 and try to link to it with compiler 2, you have a similar issue.
Do you have an objection to char
?
from qdldl.
Not really, no. It was unclear to me when writing this whether forcing the type to be 8 bits exactly might be slower than allowing it to be whatever is the most efficient size for the platform (i.e. I would have preferred int_fast8_t
, but that is also C99 only). I can't say for sure if that's anything beyond a hypothetical concern though.
from qdldl.
That's also hard to test since I don't know on which platforms int_fast8_t
is strictly larger than char
.
If char
is too awkward as a bool store, int
is also reasonable. You can also ask for an int*
for the bool storage in the header and cast it to something else. You have to be careful about memory alignment issues if you're casting it to a pointer to a type of a different size than int
, however.
from qdldl.
I have proposed a fix in #12 that changes the definition of the bool type to unsigned char
.
from qdldl.
fixed in #12
from qdldl.
Related Issues (16)
- Release v0.1.3 HOT 2
- etree counting error for very large matrices
- compile error issue HOT 1
- custom number types HOT 6
- [openSUSE linux] libqdldl.a does not contain a non-empty .text section. The archive was not created with -ffat-lto-objects option. HOT 3
- [openSUSE] How to move file from /usr/lib/ to /usr/lib64? HOT 2
- Compile error on raspberrypi HOT 7
- library output names HOT 1
- Compile error with Windows ninja build HOT 3
- Windows: fatal error C1083: Cannot open include file: 'qdldl_types.h' HOT 3
- [Windows] Error in cmake HOT 2
- Cannot install by py for python 3.10 HOT 3
- Implicit permutation
- Missing documentation and for how to run the tests HOT 2
- Minor compilation warnings
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from qdldl.