I'm not sure if this is intentional, but I notice that while structs can be nested inside classes, they cannot be nested inside other structs.
Because nesting can be helpful for reducing the chance of namespace collisions, please consider allowing that.
Structs may not be nested inside structs, only classes
Moderator: GZDoom Developers
Forum rules
Please construct and post a simple demo whenever possible for all bug reports. Please provide links to everything.
If you can include a wad demonstrating the problem, please do so. Bug reports that include fully-constructed demos have a much better chance of being investigated in a timely manner than those that don't.
Please make a new topic for every bug. Don't combine multiple bugs into a single topic. Thanks!
Please construct and post a simple demo whenever possible for all bug reports. Please provide links to everything.
If you can include a wad demonstrating the problem, please do so. Bug reports that include fully-constructed demos have a much better chance of being investigated in a timely manner than those that don't.
Please make a new topic for every bug. Don't combine multiple bugs into a single topic. Thanks!
- Major Cooke
- Posts: 8175
- Joined: Sun Jan 28, 2007 3:55 pm
- Preferred Pronouns: He/Him
- Location: QZDoom Maintenance Team
Re: Structs may not be nested inside structs, only classes
If that were true, Line structs wouldn't be able to store Vertex structs and so on. But then again, they're native...
Are you trying to store structs of the same type into itself? Try making it 'readonly'. That's how the Sector struct does it with the heightsec variable which is also a Sector struct.
No guarantees it'll work, that's just a theory.
Are you trying to store structs of the same type into itself? Try making it 'readonly'. That's how the Sector struct does it with the heightsec variable which is also a Sector struct.
No guarantees it'll work, that's just a theory.
- phantombeta
- Posts: 2088
- Joined: Thu May 02, 2013 1:27 am
- Operating System Version (Optional): Windows 10
- Graphics Processor: nVidia with Vulkan support
- Location: Brazil
Re: Structs may not be nested inside structs, only classes
No. He's talking about defining structs inside structs.
I'm pretty sure this is intentional. There's nothing in the ZScript syntax to allow structs nested in structs.
I'm pretty sure this is intentional. There's nothing in the ZScript syntax to allow structs nested in structs.
- Major Cooke
- Posts: 8175
- Joined: Sun Jan 28, 2007 3:55 pm
- Preferred Pronouns: He/Him
- Location: QZDoom Maintenance Team
Re: Structs may not be nested inside structs, only classes
Code: Select all
Class aa
{
Struct bb
{
int volt;
};
}
- Graf Zahl
- Lead GZDoom+Raze Developer
- Posts: 49067
- Joined: Sat Jul 19, 2003 10:19 am
- Location: Germany
Re: Structs may not be nested inside structs, only classes
This is certainly an oversight. The compiler backend can definitely handle such constructs, but it seems the grammar is incomplete.