< winnt.h>中ANYSIZE_ARRAY的目的是什么? [英] What is the purpose of ANYSIZE_ARRAY in <winnt.h>?

查看:177
本文介绍了< winnt.h>中ANYSIZE_ARRAY的目的是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

位于WinNT.h中的 ANYSIZE_ARRAY 的目的是什么?

What's the purpose of ANYSIZE_ARRAY, located in WinNT.h?

我看到有关以下内容的MSDN博客文章:从2004年开始,但对我来说却没有意义。

I see an MSDN blog post about it from 2004 but it doesn't make sense to me.

推荐答案

我假设您正在谈论此博客文章

当可变大小(在编译时未知)数组是结构的一部分时,通常使用它:

It is often used when a variable-sized (unknown at compile time) array is part of a struct:

typedef struct {
    int CommonFlags
    int CountOfThings;
    THING Things[ANYSIZE_ARRAY]; //Things[1];
} THINGSANDFLAGS;

要使用这些结构,您通常首先调用所需的API以获取数据大小,然后分配足够大的内存块,最后再次调用相同的API,以便可以填充数据...

To work with those structures you often first call the desired API to get the size of the data, then allocate a block of memory big enough and finally call the same API again so it can fill in the data...

这篇关于< winnt.h>中ANYSIZE_ARRAY的目的是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆