[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: а кто C хорошо знает?



On 2012-10-09, yuri.nefedov@gmail.com wrote:

> On Tue, 9 Oct 2012, Oleksandr Gavenko wrote:
>
>> по ключевым словам:
>>
>>  flexible array member
>>
>
>   Речь шла не о flexible arrays, а о использовании structure/unit
>   и о том, что поля в них могут хранится разрежено. По стандарту.
>   И размер дыры между полями заранее угадать нельзя.
>
Речь шла о "flexible array member". Стандарт определяет следующие возможности
и ограничения для "flexible array member":

  6.7.2.1 Structure and union specifiers

  There are a few restrictions on flexible array members that ensure that code
  using them makes sense. For example, there must be at least one other member,
  and the flexible array must occur last. Similarly, structures containing
  flexible arrays can't occur in other structures or in arrays. Finally,
  sizeof applied to the structure ignores the array but counts any padding
  before it. This makes the malloc call as simple as possible.

-- 
Best regards!


Reply to: