Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with installing on Mac #449

Closed
josephinius opened this issue Aug 27, 2024 · 9 comments
Closed

Problem with installing on Mac #449

josephinius opened this issue Aug 27, 2024 · 9 comments
Labels
compile/build issues related to compiling/building processes Top priority The Issue that has top priority

Comments

@josephinius
Copy link

josephinius commented Aug 27, 2024

First, I had to add add_compile_options(-Wno-c++11-narrowing) into CMakeLists.txt to get rid of this error:

error: non-constant-expression cannot be narrowed from type 'value_type' (aka 'int') to 'unsigned long long' in initializer list [-Wc++11-narrowing]
        auto eigTens = P_inv.at({0, maxIdx}) * qs[0];

But I still have the following error while installing:

error: implicit conversion from '_Complex double' to 'double' is not permitted in C++
        od[0] *= (cytnx_complex128)_Rin[i * N + i];

I use clang as a compiler.

@manuschneider manuschneider added Top priority The Issue that has top priority compile/build issues related to compiling/building processes labels Aug 27, 2024
@yingjerkao
Copy link
Collaborator

The first one can be resolved by explicit casting.

error: implicit conversion from '_Complex double' to 'double' is not permitted in C++
        od[0] *= (cytnx_complex128)_Rin[i * N + i];

Can you tell me where it occurs?

Here is a related fix
tfhe/tfhe#213

@josephinius
Copy link
Author

Here are the whole error messages:

/Cytnx/src/backend/linalg_internal_cpu/Det_internal.cpp:31:36: error: implicit conversion from '_Complex double' to 'double' is not permitted in C++
        od[0] *= (cytnx_complex128)_Rin[i * N + i];
                 ~                 ^~~~~~~~~~~~~~~
/Cytnx/src/backend/linalg_internal_cpu/Det_internal.cpp:55:35: error: implicit conversion from '_Complex float' to 'float' is not permitted in C++
        od[0] *= (cytnx_complex64)_Rin[i * N + i];

@IvanaGyro
Copy link
Collaborator

#455 fixed the no-c++11-narrowing problem. For the implicit conversion, I can't reproduce the error while using clang++. @josephinius, does the error still happen?

@pcchen
Copy link
Collaborator

pcchen commented Sep 1, 2024

with commit 0be640d
and clang version:
-- The CXX compiler identification is AppleClang 15.0.0.15000309
-- The C compiler identification is AppleClang 15.0.0.15000309

I still encounter this

[ 83%] Building CXX object CMakeFiles/cytnx.dir/src/backend/linalg_internal_cpu/Ger_internal.cpp.o
/Users/pcchen/github/Cytnx/src/backend/linalg_internal_cpu/Det_internal.cpp:31:36: error: implicit conversion from '_Complex double' to 'double' is not permitted in C++
        od[0] *= (cytnx_complex128)_Rin[i * N + i];
                 ~                 ^~~~~~~~~~~~~~~
/Users/pcchen/github/Cytnx/src/backend/linalg_internal_cpu/Det_internal.cpp:55:35: error: implicit conversion from '_Complex float' to 'float' is not permitted in C++
        od[0] *= (cytnx_complex64)_Rin[i * N + i];
                 ~                ^~~~~~~~~~~~~~~
2 errors generated.

@IvanaGyro
Copy link
Collaborator

A solution was given in #461. I am not sure if the change really suppress the error of invalid conversion because I cannot reproduce on CentOS with clang and the online clang compiler either.

圖片

Someone who has Mac can try to build the code below with clang++ and see if it can be successfully compiled. If it is not passed, there may be a bug in Mac's clang.

#include <complex.h>
#include <iostream>
#include <complex>


int main() {
    double _Complex c_type_right = 123.4 + 45435.1I;
    std::complex<double> cpp_type_right{23, 23};
    std::complex<double> left{43.4, 2532.1};
    left *= (std::complex<double>)c_type_right;
    left *= (std::complex<double>)cpp_type_right;

    std::cout << std::complex<float>{c_type_right} << std::endl;
}

@josephinius
Copy link
Author

@IvanaGyro I tried to compile the code

#include <complex.h>
#include <iostream>
#include <complex>

int main() {
    double _Complex c_type_right = 123.4 + 45435.1I;
    std::complex<double> cpp_type_right{23, 23};
    std::complex<double> left{43.4, 2532.1};
    left *= (std::complex<double>)c_type_right;
    left *= (std::complex<double>)cpp_type_right;

    std::cout << std::complex<float>{c_type_right} << std::endl;
}

using Apple clang version 15.0.0 (clang-1500.3.9.4); I got the error:

complex_example.cpp:10:35: error: implicit conversion from '_Complex double' to 'double' is not permitted in C++
left *= (std::complex)c_type_right;
~ ^~~~~~~~~~~~
complex_example.cpp:13:38: error: implicit conversion from '_Complex double' to 'float' is not permitted in C++
std::cout << std::complex{c_type_right} << std::endl;
~~~ ^~~~~~~~~~~~
2 errors generated.

@IvanaGyro
Copy link
Collaborator

It seems that #461 has resolve this issue.
Apple Clang missed some features. We may consider not to support Apple Clang.

@kaihsin
Copy link
Member

kaihsin commented Sep 14, 2024

Which c++ version are we targeting? I would suggest target C++24 (don't use anything that is too new)

And If to possible please write the code that could cover most of the compilers ( specifically clang has more restrictions compared to g++, so I suggest to target clang when developing).

@pcchen
Copy link
Collaborator

pcchen commented Sep 15, 2024

Also. Apple's clang (Apple clang) is different from the typical clang. The behavior is different from the clang one installs on Mac via homebrew.......

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compile/build issues related to compiling/building processes Top priority The Issue that has top priority
Projects
None yet
Development

No branches or pull requests

6 participants