使用 offsetof 并在 android ndk 中包含 termios.h 时存储大小不恒定

问题描述 投票:0回答:0

我在编译这个的时候遇到了一个奇怪的错误

#include <termios.h>
#include <stddef.h>
struct Test {
    int a;
    int b;
};
void test() {
    static int test_array[(offsetof(struct Test,a)) > 0 ? 2 : 1];
}

使用 arm-linux-androideabi-gcc -c:

test.c:8:13: error: storage size of 'test_array' isn't constant

奇怪的是,当我删除

#include <termios.h>

整个编译没有错误。此外,当我使用安装在我的 ubuntu 系统上的 gcc 时,它不会独立于包含 termios.h 而抱怨。 谁知道为什么?

背景:我正在尝试编译一个 ghc(glasgow haskell 编译器)android crosscompiler,而 hs2hsc 在这种情况下失败。

c compiler-errors android-ndk termios
© www.soinside.com 2019 - 2024. All rights reserved.