On 07/23/2014 08:27 AM, Jose Fonseca wrote:
> On 23/07/14 16:25, Jose Fonseca wrote:
>> On 23/07/14 04:31, Emil Velikov wrote:
>>> + PIXELFORMATDESCRIPTOR pfd = {
>>> + sizeof(PIXELFORMATDESCRIPTOR),
>>> + 1,
>>> + PFD_SUPPORT_OPENGL |
>>> + PFD_DRAW_TO_WINDOW |
>>> + PFD_DOUBLEBUFFER,
>>> + PFD_TYPE_RGBA,
>>> + 32,
>>> + 0, 0, 0, 0, 0, 0,
>>> + 0,
>>> + 0,
>>> + 0,
>>> + 0, 0, 0, 0,
>>> + 16,
>>> + 0,
>>> + 0,
>>> + PFD_MAIN_PLANE,
>>> + 0,
>>> + 0, 0, 0,
>>
>> It's hard to interpret this like this. memset(0) and then writing the
>> fiels would make the code smaller and easier to read.
I agree with Jose, this is hard to read. Initialization of named members would
be better.
As an alternative to memset(0), you can zero-fill the struct at the declaration
site with
the syntax below, eliminating a line of code and a function call. This is
available in ANSI C,
no C99 or GNU required.
PIXELFORMATDESCRIPTOR pfd = {0};
The initialization behavior for structs on the stack is this: if the braces
specify the
initialization of any member, then all unspecified members are initialized to 0.
Here's the relevant language from the ANSI C Standard, Section 3.5.7
Initialization:
If there are fewer initializers in a list than there are members of
an aggregate, the remainder of the aggregate shall be initialized
implicitly the same as objects that have static storage duration.
_______________________________________________
waffle mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/waffle