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

Runtime error #1

Open
BrinthaVP opened this issue May 3, 2023 · 2 comments
Open

Runtime error #1

BrinthaVP opened this issue May 3, 2023 · 2 comments

Comments

@BrinthaVP
Copy link

Hi,

I am trying to use numpy_random library for my project. But facing some issues.

First I build the code using the command cmake CmakeFiles.txt and then copied the src/numpy_random.h to the directory that contains the code in the sample in a file trial.cpp.

I ran the trial.cpp using the command g++ -L "/data/users/numpy_random" -std=c++11 trial.cpp

But I am getting errors like this:

'''
trial.cpp: In function 'int main()':
trial.cpp:12:23: error: 'class RandomState<std::mersenne_twister_engine<long unsigned int, 32, 624, 397, 31, 2567483615, 11, 4294967295, 7, 2636928640, 15, 4022730752, 18, 1812433253> >' has no member named 'rand_int'
std::cout << random.rand_int(0, 9) << std::endl;
^~~~~~~~
trial.cpp:13:23: error: 'class RandomState<std::mersenne_twister_engine<long unsigned int, 32, 624, 397, 31, 2567483615, 11, 4294967295, 7, 2636928640, 15, 4022730752, 18, 1812433253> >' has no member named 'rand_int'
std::cout << random.rand_int(0, 9) << std::endl;
^~~~~~~~
trial.cpp:14:23: error: 'class RandomState<std::mersenne_twister_engine<long unsigned int, 32, 624, 397, 31, 2567483615, 11, 4294967295, 7, 2636928640, 15, 4022730752, 18, 1812433253> >' has no member named 'rand_int'
std::cout << random.rand_int(0, 9) << std::endl;
^~~~~~~~
trial.cpp:15:23: error: 'class RandomState<std::mersenne_twister_engine<long unsigned int, 32, 624, 397, 31, 2567483615, 11, 4294967295, 7, 2636928640, 15, 4022730752, 18, 1812433253> >' has no member named 'rand_int'
std::cout << random.rand_int(0, 9) << std::endl;
^~~~~~~~
In file included from trial.cpp:3:0:
numpy_random.h: In instantiation of 'RandomState::RandomState(Ts&& ...) [with Ts = {RandomState<std::mersenne_twister_engine<long unsigned int, 32, 624, 397, 31, 2567483615, 11, 4294967295, 7, 2636928640, 15, 4022730752, 18, 1812433253> >}; RngEngine = std::mersenne_twister_engine<long unsigned int, 32, 624, 397, 31, 2567483615, 11, 4294967295, 7, 2636928640, 15, 4022730752, 18, 1812433253>]':
trial.cpp:9:41: required from here
numpy_random.h:261:66: error: cannot bind non-const lvalue reference of type 'RandomState<std::mersenne_twister_engine<long unsigned int, 32, 624, 397, 31, 2567483615, 11, 4294967295, 7, 2636928640, 15, 4022730752, 18, 1812433253> >&' to an rvalue of type 'RandomState<std::mersenne_twister_engine<long unsigned int, 32, 624, 397, 31, 2567483615, 11, 4294967295, 7, 2636928640, 15, 4022730752, 18, 1812433253> >'
RandomState(Ts&&... args) : _engine{std::forward(args)...} {
'''

@BrinthaVP
Copy link
Author

On running the make command getting the following errors

In function 'SrcIter uneven_copy(SrcIter, DestIter, DestIter, std::true_type)':
user/numpy_random/src/numpy_random.h:40:47: error: 'CHAR_BIT' was not declared in this scope
constexpr uint8_t DEST_BITS = DEST_SIZE * CHAR_BIT;
^~~~~~~~
user/numpy_random/src/numpy_random.h: In function 'SrcIter uneven_copy(SrcIter, DestIter, DestIter, std::false_type)':
user/numpy_random/src/numpy_random.h:63:42: error: 'CHAR_BIT' was not declared in this scope
constexpr auto SRC_BITS = SRC_SIZE * CHAR_BIT;
^~~~~~~~
user/numpy_random/src/numpy_random.h: In function 'size_t uneven_copy_safe(const IdxRef&, size_t, DestIter, DestIter, std::true_type)':
user/numpy_random/src/numpy_random.h:89:47: error: 'CHAR_BIT' was not declared in this scope
constexpr uint8_t DEST_BITS = DEST_SIZE * CHAR_BIT;
^~~~~~~~
user/numpy_random/src/numpy_random.h: In function 'size_t uneven_copy_safe(IdxRef&, size_t, DestIter, DestIter, std::false_type)':
user/numpy_random/src/numpy_random.h:119:44: error: 'CHAR_BIT' was not declared in this scope
constexpr size_t SRC_BITS = SRC_SIZE * CHAR_BIT;
^~~~~~~~
user/numpy_random/src/numpy_random.h: At global scope:
user/numpy_random/src/numpy_random.h:165:1: error: '_INLINE_VAR' does not name a type; did you mean 'LINE'?
_INLINE_VAR constexpr bool is_static_castable_v =
^~~~~~~~~~~
LINE
user/numpy_random/src/numpy_random.h:169:48: error: 'is_static_castable_v' was not declared in this scope
struct is_static_castable : std::bool_constant<is_static_castable_v<F, T>> {};
^~~~~~~~~~~~~~~~~~~~
user/numpy_random/src/numpy_random.h:169:48: note: suggested alternative: 'is_static_castable'
struct is_static_castable : std::bool_constant<is_static_castable_v<F, T>> {};
^~~~~~~~~~~~~~~~~~~~
is_static_castable
user/numpy_random/src/numpy_random.h:169:72: error: wrong number of template arguments (2, should be 1)
struct is_static_castable : std::bool_constant<is_static_castable_v<F, T>> {};
^
anaconda3/x86_64-conda_cos6-linux-gnu/include/c++/7.3.0/type_traits:98:55: note: provided for 'template using bool_constant = std::integral_constant<bool, __v>'
using bool_constant = integral_constant<bool, __v>;
^
In file included from user/numpy_random/src/numpy_random.cpp:3:0:
user/numpy_random/src/numpy_random.h:169:73: error: expected '{' before '>' token
struct is_static_castable : std::bool_constant<is_static_castable_v<F, T>> {};
^~
user/numpy_random/src/numpy_random.h:172:1: error: '_INLINE_VAR' does not name a type; did you mean 'LINE'?
_INLINE_VAR constexpr bool is_any_static_castable_v =
^~~~~~~~~~~
LINE
user/numpy_random/src/numpy_random.h:176:1: error: '_INLINE_VAR' does not name a type; did you mean 'LINE'?
_INLINE_VAR constexpr bool is_arithmetic_castable_v =
^~~~~~~~~~~
LINE
user/numpy_random/src/numpy_random.h:242:32: error: expected nested-name-specifier
using RngReturn = typename raw_type<decltype(std::declval()())>;
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
user/numpy_random/src/numpy_random.h:243:64: error: 'RngReturn' was not declared in this scope
static constexpr bool is_arithmetic = std::is_arithmetic_v;
^~~~~~~~~
user/numpy_random/src/numpy_random.h:244:69: error: 'RngReturn' was not declared in this scope
static constexpr bool is_container_arithmetic = valid_container();
^~~~~~~~~
user/numpy_random/src/numpy_random.h:246:9: error: 'is_arithmetic_castable_v' was not declared in this scope
is_arithmetic_castable_v && valid_custom_arithmetic();
^~~~~~~~~~~~~~~~~~~~~~~~
user/numpy_random/src/numpy_random.h:246:9: note: suggested alternative: 'is_static_castable'
is_arithmetic_castable_v && valid_custom_arithmetic();
^~~~~~~~~~~~~~~~~~~~~~~~
is_static_castable
user/numpy_random/src/numpy_random.h:246:34: error: 'RngReturn' was not declared in this scope
is_arithmetic_castable_v && valid_custom_arithmetic();
^~~~~~~~~
user/numpy_random/src/numpy_random.h:246:48: error: label 'valid_custom_arithmetic' referenced outside of any function
is_arithmetic_castable_v && valid_custom_arithmetic();
^~~~~~~~~~~~~~~~~~~~~~~
user/numpy_random/src/numpy_random.h:246:72: error: 'RngReturn' was not declared in this scope
is_arithmetic_castable_v && valid_custom_arithmetic();
^~~~~~~~~
user/numpy_random/src/numpy_random.h:246:83: error: expected primary-expression before ')' token
is_arithmetic_castable_v && valid_custom_arithmetic();
^
user/numpy_random/src/numpy_random.h: In static member function 'static constexpr bool RandomState::valid_custom_arithmetic()':
user/numpy_random/src/numpy_random.h:218:20: error: 'is_arithmetic_castable_v' was not declared in this scope
return is_arithmetic_castable_v<raw_type<type_shr>> &&
^~~~~~~~~~~~~~~~~~~~~~~~
user/numpy_random/src/numpy_random.h:218:20: note: suggested alternative: 'is_static_castable'
return is_arithmetic_castable_v<raw_type<type_shr>> &&
^~~~~~~~~~~~~~~~~~~~~~~~
is_static_castable
user/numpy_random/src/numpy_random.h:218:62: error: expected primary-expression before '>' token
return is_arithmetic_castable_v<raw_type<type_shr>> &&
^~
user/numpy_random/src/numpy_random.h:219:62: error: expected primary-expression before '>' token
is_arithmetic_castable_v<raw_type<type_and>>;
^~
user/numpy_random/src/numpy_random.h:219:64: error: expected primary-expression before ';' token
is_arithmetic_castable_v<raw_type<type_and>>;
^
user/numpy_random/src/numpy_random.h: In member function 'T RandomState::beta(T, T)':
user/numpy_random/src/numpy_random.h:281:19: error: there are no arguments to 'legacy_beta' that depend on a template parameter, so a declaration of 'legacy_beta' must be available [-fpermissive]
return (T)legacy_beta(_internal_state._aug_state, (double)a, (double)b);
^~~~~~~~~~~
user/numpy_random/src/numpy_random.h:281:19: note: (if you use '-fpermissive', G++ will accept your code, but allowing the use of an undeclared name is deprecated)
user/numpy_random/src/numpy_random.h: In member function 'int64_t RandomState::binomial(T, U)':
user/numpy_random/src/numpy_random.h:291:16: error: there are no arguments to 'legacy_random_binomial' that depend on a template parameter, so a declaration of 'legacy_random_binomial' must be available [-fpermissive]
return legacy_random_binomial(_internal_state._bitgen, (double)p, (int64_t)n,
^~~~~~~~~~~~~~~~~~~~~~
user/numpy_random/src/numpy_random.h: In member function 'T RandomState::uniform(T, T)':
user/numpy_random/src/numpy_random.h:306:14: error: there are no arguments to 'isfinite' that depend on a template parameter, so a declaration of 'isfinite' must be available [-fpermissive]
if (!isfinite(range) || _internal_state._bitgen == nullptr) {
^~~~~~~~
user/numpy_random/src/numpy_random.h: In static member function 'static uint64_t RandomState::get_raw(void*)':
user/numpy_random/src/numpy_random.h:454:17: error: 'RngReturn' was not declared in this scope
RngReturn container = _engine();
^~~~~~~~~
user/numpy_random/src/numpy_random.h:455:53: error: 'container' was not declared in this scope
_uintegers_cnt += copy_to_container(container, _uintegers);
^~~~~~~~~
user/numpy_random/src/numpy_random.h:458:57: error: 'RngReturn' was not declared in this scope
if constexpr (sizeof(uint64_t) < sizeof(RngReturn)) {
^~~~~~~~~
user/numpy_random/src/numpy_random.h:459:31: error: expected ';' before 'container'
RngReturn container[1]{_engine()};
^~~~~~~~~
user/numpy_random/src/numpy_random.h:460:57: error: 'container' was not declared in this scope
_uintegers_cnt += copy_to_container(container, _uintegers);
^~~~~~~~~
user/numpy_random/src/numpy_random.h: In static member function 'static T RandomState::get(void*)':
user/numpy_random/src/numpy_random.h:477:63: error: 'RngReturn' was not declared in this scope
(is_arithmetic || is_custom_arithmetic) && sizeof(RngReturn) <= sizeof(uint32_t);
^~~~~~~~~
user/numpy_random/src/numpy_random.h:485:35: error: the value of 'IS_32BIT' is not usable in a constant expression
if constexpr (IS_32BIT) {
^
user/numpy_random/src/numpy_random.h:500:35: error: the value of 'IS_32BIT' is not usable in a constant expression
if constexpr (IS_32BIT) {
^
user/numpy_random/src/numpy_random.h: In static member function 'static double RandomState::next_double(void*)':
user/numpy_random/src/numpy_random.h:522:34: error: 'RngReturn' was not declared in this scope
if constexpr (sizeof(RngReturn) <= sizeof(uint32_t)) {
^~~~~~~~~
user/numpy_random/src/numpy_random.h: In constructor 'NumpySeedSequence<result_type, pool_size>::NumpySeedSequence(const std::vector&)':
user/numpy_random/src/numpy_random.h:615:46: error: no matching function for call to 'internal_numpy_seed_sequence::set_entropy(std::remove_reference<const std::vector&>::type)'
_inner.set_entropy(std::move(entropy));
^
user/numpy_random/src/numpy_random.h:570:10: note: candidate: void internal_numpy_seed_sequence::set_entropy(std::vector&&)
void set_entropy(std::vector<uint32_t>&&);
^~~~~~~~~~~
user/numpy_random/src/numpy_random.h:570:10: note: conversion of argument 1 would be ill-formed:
user/numpy_random/src/numpy_random.h: In member function 'void NumpySeedSequence<result_type, pool_size>::generate(DestIter, DestIter)':
user/numpy_random/src/numpy_random.h:647:18: error: 'reverse' is not a member of 'std'
std::reverse(start, finish);
^~~~~~~
make[2]: *** [src/CMakeFiles/numpy_random.dir/numpy_random.cpp.o] Error 1
make[1]: *** [src/CMakeFiles/numpy_random.dir/all] Error 2
make: *** [all] Error 2

@IamSanjid
Copy link
Owner

IamSanjid commented May 5, 2023

By passing the argument -std=c++11, you are instructing GCC to use C++ 11. However, in order to compile it, you will need to use the appropriate compiler flags or options to use C++ 17.

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

No branches or pull requests

2 participants