View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0000648 | LDMud | LPC Compiler/Preprocessor | public | 2009-06-01 05:56 | 2022-10-06 20:13 |
Reporter | _xtian_ | Assigned To | Gnomi | ||
Priority | normal | Severity | minor | Reproducibility | always |
Status | closed | Resolution | won't fix | ||
Summary | 0000648: struct declarations need to be defined in the same object | ||||
Description | From 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 Information | Beeing 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. | ||||
Tags | No tags attached. | ||||
External Data (URL) | |||||
duplicate of | 0000579 | new | LDMud 3.5 | Allow struct prototypes and definitions to be in different programs |
|
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. |
|
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. |
|
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. |
Date Modified | Username | Field | Change |
---|---|---|---|
2009-06-01 05:56 | _xtian_ | New Issue | |
2009-06-01 06:30 | zesstra | Note Added: 0001179 | |
2009-06-01 07:01 | zesstra | Relationship added | has duplicate 0000579 |
2009-06-01 07:03 | zesstra | Relationship deleted | has duplicate 0000579 |
2009-06-01 07:03 | zesstra | Relationship added | duplicate of 0000579 |
2021-04-08 16:30 | Gnomi | Note Added: 0002571 | |
2022-10-06 20:13 | Gnomi | Assigned To | => Gnomi |
2022-10-06 20:13 | Gnomi | Status | new => closed |
2022-10-06 20:13 | Gnomi | Resolution | open => won't fix |
2022-10-06 20:13 | Gnomi | Note Added: 0002698 |