Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why doesn't struct declaration compile in Android NDK?

How can a struct be compiled with Android NDK?

The following declaration (works fine with g++)

#include <stdio.h>
#include <stdlib.h>
#include <sys/socket.h>
#include <netdb.h>
#include <cstring>
#include <fstream>
#include <sstream>

//header construction here...
    private:
      struct sockaddr_in serv_addr;

gives the error:

error: field 'serv_addr' has incomplete type
struct sockaddr_in serv_addr;
                   ^
like image 304
user2212461 Avatar asked Jun 18 '26 07:06

user2212461


1 Answers

You need to add #include <netinet/in.h>

like image 166
David Berry Avatar answered Jun 20 '26 22:06

David Berry



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!