How can I use the crate : “bech32-no_std” in rust? - rust

In Cargo.toml, I add the code:
[dependencies]
bech32-no_std = "0.7.3"
When I want to use it:
use bech32-no_std::{u5, CheckBase32};
This raised an error:
Syntax Error: expected BANGrust-analyzer
Syntax Error: expected `{`, `[`, `(`rust-analyzer
Syntax Error: expected SEMICOLONrust-analyzer
unresolved macro `self::no_std!`rust-analyzerunresolved-macro-call
This may be caused by no_std. It should be just a grammatical problem, but i don't know how to solve it.

Related

Unknown argument type '__attribute__' in method RCTAppState. Extend RCTConvert to support this type

Got the following error running a react-native app on iOS:
Xcode 11 Error: "Unknown argument type '__attribute__' in method -[RCTAppState getCurrentAppState:error:]. Extend RCTConvert to support this type."
Solution taken from here:
This is a 0.59 version bug.
Edit the following file:
react-native/React/Base/RCTModuleMethod.mm
Add in line 94:
RCTReadString(input, "__attribute__((__unused__))") ||

Why are multiple imports from the Hyper crate failing?

I'm working on a very simple HTTP client in Rust, built on top of the hyper (GitHub, crates.io) crate.
When I try to replicate the examples/client.rs file in a new Cargo project using cargo build (as well as using rustc src/main.rs), I get multiple errors caused by failed imports from hyper.
Here's the top of my main.rs:
extern crate hyper;
use hyper::client::{Client, Request, Response, DefaultTransport as HttpStream};
use hyper::header::Connection;
use hyper::{Decoder, Encoder, Next};
The rest of the file is, except for some comments, identical to the examples/client.rs file from the hyper repository.
At compile time, I get the following errors:
src/main.rs:10:48: 10:78 error: unresolved import `hyper::client::DefaultTransport`. There is no `DefaultTransport` in `hyper::client` [E0432]
src/main.rs:10 use hyper::client::{Client, Request, Response, DefaultTransport as HttpStream};
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/main.rs:10:48: 10:78 help: run `rustc --explain E0432` to see a detailed explanation
src/main.rs:12:13: 12:20 error: unresolved import `hyper::Decoder`. There is no `Decoder` in `hyper` [E0432]
src/main.rs:12 use hyper::{Decoder, Encoder, Next};
^~~~~~~
src/main.rs:12:13: 12:20 help: run `rustc --explain E0432` to see a detailed explanation
src/main.rs:12:22: 12:29 error: unresolved import `hyper::Encoder`. There is no `Encoder` in `hyper` [E0432]
src/main.rs:12 use hyper::{Decoder, Encoder, Next};
^~~~~~~
src/main.rs:12:22: 12:29 help: run `rustc --explain E0432` to see a detailed explanation
src/main.rs:12:31: 12:35 error: unresolved import `hyper::Next`. There is no `Next` in `hyper` [E0432]
src/main.rs:12 use hyper::{Decoder, Encoder, Next};
^~~~
src/main.rs:12:31: 12:35 help: run `rustc --explain E0432` to see a detailed explanation
src/main.rs:53:6: 53:40 error: trait `hyper::client::Handler` is not in scope [E0405]
src/main.rs:53 impl hyper::client::Handler<HttpStream> for Dump {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/main.rs:53:6: 53:40 help: run `rustc --explain E0405` to see a detailed explanation
src/main.rs:53:6: 53:40 help: you can to import it into scope: `use hyper::server::Handler;`.
In case it may contribute to this issue, here are the contents of my Cargo.toml:
name = "my_project"
version = "0.0.1"
authors = ["email#example.com"]
[dependencies]
getopts = "0.2"
hyper = "0.9.6"
[[bin]]
name = "my_project"
Some of the imports are actually working, so assuming the example in the repository is up to date, I really can't tell what's wrong. The source files of the crate look like they expose the involved types, but I'm very new to Rust so I may be misreading the files.
You are using examples from the master branch that do not work with 0.9.6 version. You can take a look at examples on the branch 0.9.6 or make cargo use hyper direct from github, writing on Cargo.toml:
[dependencies]
hyper = {git = "https://github.com/hyperium/hyper"}

Use of static_assert forbidden in Android project

I am porting some C++ code to Android. One of the source files includes a webrtc header file that causes error during compilation. I have reduced the problem to this simple code:
template <class T, int n>
struct DefaultDeleter<T[n]> {
// Never allow someone to declare something like scoped_ptr<int[10]>.
static_assert(sizeof(T) == -1, "do not use array with size as type");
};
The error I get is:
[armeabi-v7a] Compile++ thumb: dummyclient <= dummy.cpp
dummy.cpp:7:3: warning: identifier 'static_assert' will become a keyword in C++0x [-Wc++0x-compat]
dummy.cpp:5:8: error: 'DefaultDeleter' is not a template
dummy.cpp:7:17: error: expected identifier before 'sizeof'
dummy.cpp:7:17: error: expected ',' or '...' before 'sizeof'
dummy.cpp:7:70: error: ISO C++ forbids declaration of 'static_assert' with no type [-fpermissive]
The same code compiles fine on Windows and Linux. Is there some compiler settings that are required for Android? Regards.
You need to pass the CPPFLAG -std=c++11.

C++ syntax error: missing ';' before 'constant'

I have the following line of code in my program -
typedef GROUP ACE_SOCK_GROUP;
That gives the following warnings and errors -
Warning 181 warning C4091: 'typedef ' : ignored on left of 'int' when no variable is declared
Error 182 error C2143: syntax error : missing ';' before 'constant'
Error 183 error C2059: syntax error : 'constant'
The definition of GROUP is given in another file that is included by my program as -
typedef unsigned int GROUP;
What does 'constant' here refer to?
What could be causing the error?
What is the warning indicating
I am using Visual Studio 2008 and found the definition of GROUP using the F12 function
The code is correct.
You're forgetting to include the file where GROUP is defined.
You can try a simple test to confirm this is the issue:
typedef unsigned int GROUP;
typedef GROUP ACE_SOCK_GROUP;
If this compiles, and it will, that means that the previous definition of GROUP is not seen. You need to include the file with the definition before defining ACE_SOCK_GROUP.

when I include atomic.h, GCC says No such file, why?

I want to use atomic API, and I include . I don't know how to use it! Thank you!
I have it in /usr/src/linux-headers-2.6.28-11/arch/x86/include/asm/atomic.h.
I also add -I/usr/src/linux-headers-2.6.28-11/arch/x86/include/ and -I/usr/src/linux-headers-2.6.28-11/include.
Some other errors is produced because of -DCONFIG_X86_32 and -D__KERNEL__ macro undefined.
Then I define the two macros,
some errors occurred:
/usr/src/linux-headers-2.6.28-11/include/linux/cpumask.h:600:37: error: "and" may not appear in macro parameter list
/usr/src/linux-headers-2.6.28-11/arch/x86/include/asm/processor.h:159:1: warning: "cache_line_size" redefined
/usr/src/linux-headers-2.6.28-11/include/linux/cache.h:64:1: warning: this is the location of the previous definition
/usr/src/linux-headers-2.6.28-11/include/linux/stddef.h:16: error: expected identifier before ‘false’
/usr/src/linux-headers-2.6.28-11/include/linux/stddef.h:16: error: expected `}' before ‘false’
/usr/src/linux-headers-2.6.28-11/include/linux/stddef.h:16: error: expected unqualified-id before ‘false’
/usr/src/linux-headers-2.6.28-11/include/linux/stddef.h:18: error: expected declaration before ‘}’ token
My system is ubuntu 9.04 running on Virtualbox3.0.
If you know where the file is on your HD, then you say gcc mySource.c -I/path/to/atomic
note that this assumes you include "atomic" directly. and not "some/path/atmomic.h"

Resources