View Issue Details

IDProjectCategoryView StatusLast Update
0000648LDMudLPC Compiler/Preprocessorpublic2022-10-06 22:13
Reporter_xtian_ Assigned ToGnomi  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionwon't fix 
Summary0000648: struct declarations need to be defined in the same object
DescriptionFrom the documentation:

This works if it is in the same file:

struct Quux;

struct Bar {
  struct Quux quux;
};

struct Quux { // Quux needs to be in the same file
};

... but does not work if Quux is not defined in the same file, even if Bar it is not used or even instantiated in this file.

The check if all struct declarations have been defined should only happen when such a struct is being used (ie a variable is being instantiated, it is used in a function definition).
Additional InformationBeeing able to declare structs that will be only fully defined in a later object makes it easier to share struct definitions between files.

This should compile:

struct Quux;
struct Bar {
  struct Quux quux;
};

... and only throw the error later if Bar is used without Quux beeing fully defined.
TagsNo tags attached.
External Data (URL)

Relationships

duplicate of 0000579 new LDMud 3.5 Allow struct prototypes and definitions to be in different programs 

Activities

zesstra

2009-06-01 08:30

administrator   ~0001179

Well... Structs are tied to the program they are defined in. Technically, even recompiling a program with struct defintions creates a new struct, although the driver tries to merge the two definitions if they are identical and from the same file.
I don't know, if there a way to relate from a struct bla; in an arbitrary file, that this is meant to be struct bla from /std/comm.c.

Gnomi

2021-04-08 18:30

manager   ~0002571

Technically speaking you want something like C++'s templates.

The struct Bar in the inherited program is just a template and not a real struct definition, because it is not allowed to be used anywhere unless struct Quux is known (i.e. the struct Bar template is instantiated with a concrete struct Quux).

There is an easier solution, just #include the struct definition in the target program. Therefore it might not be worth to implement such a template system.

Gnomi

2022-10-06 22:13

manager   ~0002698

Is described in the previous comments, this cannot work with our current type system.
You have the option of either using struct mixed (or only mixed) or using includes to simulate variadic structs.

Issue History

Date Modified Username Field Change
2009-06-01 07:56 _xtian_ New Issue
2009-06-01 08:30 zesstra Note Added: 0001179
2009-06-01 09:01 zesstra Relationship added has duplicate 0000579
2009-06-01 09:03 zesstra Relationship deleted has duplicate 0000579
2009-06-01 09:03 zesstra Relationship added duplicate of 0000579
2021-04-08 18:30 Gnomi Note Added: 0002571
2022-10-06 22:13 Gnomi Assigned To => Gnomi
2022-10-06 22:13 Gnomi Status new => closed
2022-10-06 22:13 Gnomi Resolution open => won't fix
2022-10-06 22:13 Gnomi Note Added: 0002698