相关疑难解决方法(0)

C99 stdint.h头文件和MS Visual Studio

令我惊讶的是,我刚刚发现MS Visual Studio 2003向上缺少C99 stdint.h.我确定他们有他们的理由,但有谁知道我可以在哪里下载副本?如果没有这个头文件,我就没有uint32_t等有用类型的定义.

c c++ c99 visual-studio

113
推荐指数
6
解决办法
13万
查看次数

带有bools的C++ bitfield打包

我刚刚用bitfields做了一个测试,结果令我感到惊讶.

class test1 {
public:
    bool test_a:1;
    bool test_b:1;
    bool test_c:1;
    bool test_d:1;
    bool test_e:1;
    bool test_f:1;
    bool test_g:1;
    bool test_h:1;
};

class test2 {
public:
    int test_a:1;
    int test_b:1;
    int test_c:1;
    int test_d:1;
    int test_e:1;
    int test_f:1;
    int test_g:1;
    int test_h:1;
};

class test3 {
public:
    int test_a:1;
    bool test_b:1;
    int test_c:1;
    bool test_d:1;
    int test_e:1;
    bool test_f:1;
    int test_g:1;
    bool test_h:1;
};
Run Code Online (Sandbox Code Playgroud)

结果如下: -

sizeof(test1) = 1   // This is what I'd expect. 8 bits in a byte …
Run Code Online (Sandbox Code Playgroud)

c++ bit-fields

30
推荐指数
4
解决办法
3万
查看次数

标签 统计

c++ ×2

bit-fields ×1

c ×1

c99 ×1

visual-studio ×1