Opened 3 years ago
Closed 3 years ago
#63980 closed defect (fixed)
qca-qt5 @2.3.4: error: no member named 'rand' in namespace 'std'
Reported by: | ryandesign (Ryan Carsten Schmidt) | Owned by: | RJVB (René Bertin) |
---|---|---|---|
Priority: | Normal | Milestone: | |
Component: | ports | Version: | 2.7.1 |
Keywords: | Cc: | chrstphrchvz (Christopher Chavez), mascguy (Christopher Nielsen) | |
Port: | qca |
Description
error: no member named 'rand' in namespace 'std'; did you mean simply 'rand'? buf[n] = (char)std::rand(); ^~~~~~~~~ rand /usr/include/stdlib.h:159:6: note: 'rand' declared here int rand(void); ^
Change History (8)
comment:1 Changed 3 years ago by chrstphrchvz (Christopher Chavez)
comment:2 Changed 3 years ago by chrstphrchvz (Christopher Chavez)
Cc: | chrstphrchvz added |
---|
comment:3 Changed 3 years ago by RJVB (René Bertin)
Thanks. Yes, I guess that my compilers didn't trip over this, but one of them tripped in a similar way over std::unique_ptr
(hence the corresponding patchfile).
comment:4 follow-up: 7 Changed 3 years ago by jmroot (Joshua Root)
By the standard, including a C compatibility header (like stdlib.h
) will declare the appropriate names in the global namespace, and may declare the same names in the std namespace. Fun, huh?
comment:5 Changed 3 years ago by mascguy (Christopher Nielsen)
Cc: | mascguy added |
---|
comment:6 Changed 3 years ago by RJVB (René Bertin)
Fun indeed... I just observe that the documentation provided via cpppreferences suggests including the specific header for these symbols.
comment:7 Changed 3 years ago by chrstphrchvz (Christopher Chavez)
Replying to jmroot:
By the standard, including a C compatibility header (like
stdlib.h
) will declare the appropriate names in the global namespace, and may declare the same names in the std namespace. Fun, huh?
I didn’t notice stdlib.h being included, though I guess clang wouldn’t suggest using C functions rand()
/srand()
if stdlib.h weren’t included.
comment:8 Changed 3 years ago by chrstphrchvz (Christopher Chavez)
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Missing
#include <cstdlib>
forstd::rand()
andstd::srand()
(something compilers are not always strict about)? https://github.com/macports/macports-ports/pull/13010