When compiling the test with `gcc -std=c11 -fsyntax-only`
compilable/test22807.c:10:10: error: unknown type name ‘OldFashionedHeader’
10 | int peek(OldFashionedHeader *head){
| ^~~~~~~~~~~~~~~~~~
Test content:
```
struct OldFashionedHeader {
int n; // number of entries in buff
char buff[1];
};
int peek(OldFashionedHeader *head){
if(head->n < 2)
return 0;
return head->buff[1]; // do not give array bounds error
}
```
Comment #1 by bugzilla — 2023-02-20T07:00:57Z
ImportC deals with tag name spaces like C++ does. I.e. they are distinct only if there is both a tag name declaration and a regular name declaration both in the same scope.
It shouldn't cause any more trouble than using a C++ compiler to compile C code.
Comment #2 by ibuclaw — 2023-02-20T11:09:27Z
(In reply to Walter Bright from comment #1)
> ImportC deals with tag name spaces like C++ does. I.e. they are distinct
> only if there is both a tag name declaration and a regular name declaration
> both in the same scope.
>
> It shouldn't cause any more trouble than using a C++ compiler to compile C
> code.
There is a passing reference to this under Tag Symbols
https://dlang.org/spec/importc.html#tag-symbols
It sort of gets lost in the ether as a lot of the focus of that section points to the ImportC limitations, rather than extensions.
Comment #3 by ibuclaw — 2023-02-20T11:31:03Z
The term used by C++ is "elaborated type specifier", which is used to distinguish between types and regular identifiers.
For example, the following code is accepted by both C++ and ImportC
```
struct s { int a; };
void g(int s) {
struct s* p = (struct s*)malloc(sizeof(struct s));
p->a = s;
}
```
Whereas this is rejected by both C++ and ImportC, for the same reason.
```
struct s { int a; };
void g(int s) {
s* p = (s*)malloc(sizeof(s));
p->a = s;
}
```
Comment #4 by dlang-bot — 2023-04-10T18:21:55Z
@WalterBright created dlang/dlang.org pull request #3581 "fix Issue 23699 - ImportC: Unclear documentation that struct/union/en…" fixing this issue:
- fix Issue 23699 - ImportC: Unclear documentation that struct/union/enum introduce implicit typedefs
https://github.com/dlang/dlang.org/pull/3581
Comment #5 by dlang-bot — 2023-04-10T18:55:53Z
dlang/dlang.org pull request #3581 "fix Issue 23699 - ImportC: Unclear documentation that struct/union/en…" was merged into master:
- 5cbb87c50a592154f72f8cf71446b76ad057f1a8 by Walter Bright:
fix Issue 23699 - ImportC: Unclear documentation that struct/union/enum introduce implicit typedefs
https://github.com/dlang/dlang.org/pull/3581