Closed tocic closed 1 year ago
Will look into it.
For now: does it help if you add #include "mimalloc.h"
before including cista.h
?
I guess you want to use cista in a project that uses mimalloc? Otherwise, I would remove mimalloc.h from the headers that are visible when compiling the your project.
Yes, adding #include "mimalloc.h"
anywhere before the mi_malloc_aligned
use leads to successfull compilation, but you also need to link to the library (-lmimalloc
) in order to get rid of the "undefined reference" errors.
No, I don't need mimalloc
for now, just wanted to compile the simple example from the README.
Currently, the assumption is that if you have the mimalloc.h
available as an include, then you want to use mimalloc. Maybe this is not the right way to do it and cista should have a flag CISTA_WITH_MIMALLOC=1
to indicate that you want to use mimalloc.
In my case, the mimalloc
package is just a dependency of another, unrelated project, mold
, so I definitely didn't want to use mimalloc
here. I think a more correct assumption would be that if you have already included the mimalloc.h
header in your project, then you want to use it in cista
. In this case, you should check for the presence of some predefined macro like MI_MALLOC_VERSION
instead of the header existance. Your suggestion to explicitly request mimalloc
works too.
Anyway, the problem at hand is that in the amalgamated file after checking for the existence of the header, we assume that it is already included. I think the easiest solution is to change the aforementioned line as follows:
25c25
< #include "mimalloc.h"
---
> #include <mimalloc.h>
Now, uniter.cc
ignores this line and the amalgamated file will change as follows:
1978c1978
< // mimalloc.h: basic_ios::clear: iostream error
---
> #include <mimalloc.h>
But then you still need to link to the library in order to use its functions.
I think the CISTA_WITH_MIMALLOC
gives the use more options to have mimalloc installed but not use it. #159 fixes it. Please reopen / create a new issue if the change causes new issues. Thank you very much for bringing up this issue!
Thank you for the quick resolution! Do you plan to update the release assets soon or is it better to manually build cista.h
from the top master's commit?
Every PR build produces a cista.h
artifact that can be downloaded from the "Actions" tab (requires login) if no release is available.
The new v0.11 contains the changes from this PR.
mkdir test && cd test
wget https://github.com/felixguendling/cista/releases/download/v0.10/cista.h
echo '#include "cista.h"' > main.cpp
clang++ -std=c++17 main.cpp
leads to
Seems like this line is missing from the amalgamated file.