In6_addr __align that was not provided

I was following Luca Palmieri's book, Zero To Production. I didn't get far before I got this on an Ubuntu VM on VMware:

error: cannot construct in6_addr with struct literal syntax due to private fields
...and other private field __align that was not provided

However, running this on a Debian 10 VM and another Devbian 12 VM on Parallels is just fine. Any ideas?

It's impossible to tell what's wrong without further context. What's the full error message, and specifically where and when are you getting it?

There's not much else to the error even with full backtrace

rror: cannot construct in6_addr with struct literal syntax due to private fields
--> ~/.cargo/registry/src/index.crates.io-6f17d22bba15001f/socket2-0.5.7/src/sys/unix.rs:1355:5
|
1355 | in6_addr {
| ^^^^^^^^
|
= note: ...and other private field __align that was not provided

Here's the code

use actix_web::{web, App, HttpRequest, HttpServer, Responder};
     async fn greet(req: HttpRequest) -> impl Responder {
     let name = req.match_info().get("name").unwrap_or("World");
    format!("Hello {}!", &name)
}

#[tokio::main]
async fn main() -> Result<(), std::io::Error> {
    HttpServer::new(|| {
        App::new()
         .route("/", web::get().to(greet))
        .route("/{name}", web::get().to(greet))
     })
      .bind("127.0.0.1:8000")?
      .run()
     .await
}

Backtrace settings can't affect this error – it's a compile-time error, not a runtime one.

Ah-ha! So it's in the crate socket2. Which in turn imports in6_addr from libc. It's here in libc.

It looks like some platform's libc either contains such a dummy field, or bindgen mistakenly generates an alignment-ensuring field instead of the correct #[repr(align(4))].

You should probably ask the maintainers of the libc crate for more specific help.

2 Likes

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.