android - 为什么在 Android NDK 中不编译结构声明?

标签 android c++ c struct android-ndk

如何使用 Android NDK 编译结构体?

以下声明(适用于 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;

给出错误:

error: field 'serv_addr' has incomplete type
struct sockaddr_in serv_addr;
                   ^

最佳答案

您需要添加 #include <netinet/in.h>

关于android - 为什么在 Android NDK 中不编译结构声明?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23617825/

相关文章:

Java Android - 应用程序适用于 4.4,但不适用于 2.3.5

android - 无法验证证书 - 找到 TrustAnchor 但证书验证失败

android - Crashlytics 未上传映射文件

c++ - 成员模板的别名模板

c++ - 我的头文件和 C++ 实现文件有问题

android - 禁用自动关闭应用程序 Android

c++ - 当前对象的访问类

c - C 中运算符 == 的返回类型

c - 解析多个参数行

python - 在 Python2.6+ 中为 Solaris 创建 netstat 的实现