Field initialization warnings

4 posts / 0 new
Last post
trixie
trixie's picture
Offline
Last seen: 7 months 4 weeks ago
Joined: 2011-02-03 13:58
Field initialization warnings

I'm trying to fix all warnings in a source code I've taken over from somebody else. In the code there is a function inside which the following field is initialized:

  1. struct Elf32_SymbolQuery query2[] =
  2. {
  3. { ELF32_SQ_BYNAME, "EditEncoderProfile", 0, 0, FALSE, 0, 0 },
  4. { ELF32_SQ_BYNAME, "EncoderControl", 0, 0, FALSE, 0, 0 },
  5. };

The bit of code above produces two warnings:

1. missing braces around initializer
2. near initialization for 'query2[0].Sym'

What is actually wrong here, and how do I best get rid of the warnings?

Hans
Hans's picture
Offline
Last seen: 4 months 3 weeks ago
Joined: 2010-12-09 22:04
Re: Field initialization warnings

Based on the documentation found here, I'd say that the problem is the last element in struct Elf32_SymbolQuery:

  1. struct Elf32_SymbolQuery
  2. {
  3. uint32 Flags;
  4. STRPTR Name;
  5. uint32 NameLength;
  6. uint32 Value;
  7. BOOL Found;
  8. uint16 pad1;
  9. Elf32_Sym Sym;
  10. };

AFAIK, Elf32_Sym is a typedef for another structure.

Hans

Join the Kea Campus - upgrade your skills; support my work; enjoy the Amiga corner.
https://keasigmadelta.com/ - see more of my work

salass00
salass00's picture
Offline
Last seen: 7 months 2 weeks ago
Joined: 2011-02-03 11:27
As Hans said Elf32_Sym is

As Hans said Elf32_Sym is another structure so you should change your code to:

  1. struct Elf32_SymbolQuery query2[] =
  2. {
  3. { ELF32_SQ_BYNAME, "EditEncoderProfile", 0, 0, FALSE, 0, { 0 } },
  4. { ELF32_SQ_BYNAME, "EncoderControl", 0, 0, FALSE, 0, { 0 } },
  5. };
trixie
trixie's picture
Offline
Last seen: 7 months 4 weeks ago
Joined: 2011-02-03 13:58
Re: Field initialization warnings

@Hans & salass00

Thank you very much!

AmigaOne X5000-020 / 2GB RAM / Sapphire Pulse Radeon RX 560 / AmigaOS 4.1 Final Edition Update 2

Log in or register to post comments