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

Compile errors in giac with c++ 17 #38985

Open
tobiasdiez opened this issue Nov 17, 2024 · 1 comment
Open

Compile errors in giac with c++ 17 #38985

tobiasdiez opened this issue Nov 17, 2024 · 1 comment
Labels

Comments

@tobiasdiez
Copy link
Contributor

Steps To Reproduce

Remove the line # distutils: extra_compile_args = -std=c++11 in src\sage\libs\giac\giac.pyx. Then compile (which now uses c++17)

Expected Behavior

Compiles fine

Actual Behavior

``̀
In file included from /Users/runner/miniconda3/envs/sage/include/giac/giac.h:5:
In file included from /Users/runner/miniconda3/envs/sage/include/giac/poly.h:26:
/Users/runner/miniconda3/envs/sage/include/giac/monomial.h:341:10: error: no template named 'pointer_to_binary_function' in namespace 'std'
std::pointer_to_binary_function < const monomial &, const monomial &, bool> strictly_greater ;
~~~~~^
/Users/runner/miniconda3/envs/sage/include/giac/monomial.h:342:28: error: no template named 'pointer_to_binary_function' in namespace 'std'
sort_helper(const std::pointer_to_binary_function < const monomial &, const monomial &, bool> is_strictly_greater):strictly_greater(is_strictly_greater) {};
~~~~~^
/Users/runner/miniconda3/envs/sage/include/giac/monomial.h:343:41: error: no member named 'ptr_fun' in namespace 'std'
sort_helper():strictly_greater(std::ptr_fun<const monomial &, const monomial &, bool>(m_lex_is_strictly_greater)) {};
~~~~~^
/Users/runner/miniconda3/envs/sage/include/giac/monomial.h:343:49: error: expected expression
sort_helper():strictly_greater(std::ptr_fun<const monomial &, const monomial &, bool>(m_lex_is_strictly_greater)) {};
^
/Users/runner/miniconda3/envs/sage/include/giac/monomial.h:343:70: error: expected expression
sort_helper():strictly_greater(std::ptr_fun<const monomial &, const monomial &, bool>(m_lex_is_strictly_greater)) {};
^
/Users/runner/miniconda3/envs/sage/include/giac/monomial.h:343:95: error: expected '(' for function-style cast or type construction
sort_helper():strictly_greater(std::ptr_fun<const monomial &, const monomial &, bool>(m_lex_is_strictly_greater)) {};
~~~~^
/Users/runner/miniconda3/envs/sage/include/giac/monomial.h:680:18: error: no template named 'pointer_to_binary_function' in namespace 'std'
const std::pointer_to_binary_function < const monomial &, const monomial &, bool> m_is_strictly_greater
~~~~~^
/Users/runner/miniconda3/envs/sage/include/giac/monomial.h:729:44: error: no template named 'pointer_to_binary_function' in namespace 'std'
typedef std::map< index_t,T,const std::pointer_to_binary_function < const index_m &, const index_m &, bool> > application;
~~~~~^
/Users/runner/miniconda3/envs/sage/include/giac/monomial.h:730:30: error: no type named 'ptr_fun' in namespace 'std'
application produit(std::ptr_fun(is_strictly_greater));
~~~~~^
/Users/runner/miniconda3/envs/sage/include/giac/monomial.h:737:14: error: 'application' (aka 'int') is not a class, namespace, or enumeration
typename application::iterator prod_it,prod_itend;
^
/Users/runner/miniconda3/envs/sage/include/giac/monomial.h:754:29: error: use of undeclared identifier 'prod_itend'; did you mean 'prod_it'?
prod_it=produit.begin(),prod_itend=produit.end();


### Additional Information

_No response_

### Environment

- **OS**: 
- **Sage Version**: 


### Checklist

- [X] I have searched the existing issues for a bug report that matches the one I want to file, without success.
- [X] I have read the documentation and troubleshoot guide
@user202729
Copy link
Contributor

user202729 commented Nov 25, 2024

giac/first.h:

#if __cplusplus >= 201103L
// post-c++11 functional headers changes, thanks to George Huebner
#define CPP11
#endif

giac/monomial.h:

#ifdef CPP11
    std::function<bool(const monomial<T> &, const monomial<T> &)> strictly_greater ;
    sort_helper(const std::function<bool(const monomial<T> &, const monomial<T> &)> is_strictly_greater):strictly_greater(is_strictly_greater) {};
    sort_helper():strictly_greater(m_lex_is_strictly_greater<T>) {};
#else
    std::pointer_to_binary_function < const monomial<T> &, const monomial<T> &, bool> strictly_greater ;
    sort_helper(const std::pointer_to_binary_function < const monomial<T> &, const monomial<T> &, bool> is_strictly_greater):strictly_greater(is_strictly_greater) {};
    sort_helper():strictly_greater(std::ptr_fun<const monomial<T> &, const monomial<T> &, bool>(m_lex_is_strictly_greater<T>)) {};
#endif

In principle, the error cannot happen if everything are configured correctly.

I cannot reproduce the error on my machine (either replacing 11 with 17, or delete the line entirely as you suggested).

(I'm compiling with meson however, which if I recalled correctly might not parse the # distutils file headers, but by enabling --verbose I see it is compiling with C++17 by default.)

Which compiler are you using? Could be MSVC issue ?

Or maybe your version of Giac is too old? (judging by your line number, 342, this seems likely. But where is the header pulled from? Sage's spkg?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants