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

README is not correct about how to include the generated code #17

Open
tgrushka opened this issue May 12, 2024 · 0 comments
Open

README is not correct about how to include the generated code #17

tgrushka opened this issue May 12, 2024 · 0 comments

Comments

@tgrushka
Copy link

When I follow your instructions and create this file:

// src/protocol.rs

include!(concat!(env!("OUT_DIR"), "/protocol.rs"));

I get this error:

cargo build                                                main 
   Compiling testclient v0.1.0 ...
error: environment variable `OUT_DIR` not defined at compile time
 --> testclient/src/protocol.rs:1:18
  |
1 | include!(concat!(env!("OUT_DIR"), "/protocol.rs"));
  |                  ^^^^^^^^^^^^^^^
  |
  = help: Cargo sets build script variables at run time. Use `std::env::var("OUT_DIR")` instead
  = note: this error originates in the macro `env` (in Nightly builds, run with -Z macro-backtrace for more info)

error: could not compile `testclient` (bin "testclient") due to 1 previous error

But when I do that, I obviously get the error:

1 | include!(concat!(std::env::var("OUT_DIR"), "/protocol.rs"));
  |                  ^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: only literals (like `"foo"`, `-42` and `3.14`) can be passed to `concat!()`

How do I use this project?

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

1 participant