Skip to content

Commit f62fe75

Browse files
authored
fix Issue 23699 - ImportC: Unclear documentation that struct/union/enum introduce implicit typedefs (#3581)
1 parent 0789e99 commit f62fe75

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

spec/importc.dd

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,36 @@ int myprintf(char *, ...) asm("printf");
420420
$(P Any declarations in scope can be accessed, not just
421421
declarations that lexically precede a reference.)
422422

423+
$(H3 $(LNAME2 cpp-tag-symbols, C++ Style Tag Symbols))
424+
425+
$(P In C++, `struct`, `union` or `enum` tag symbols can be accessed without needing
426+
to be prefixed with the `struct`, `union` or `enum` keywords, as long
427+
as there is no other declaration with the same name at the same scope.
428+
ImportC behaves the same way.)
429+
430+
$(P For example, the following code is accepted by both C++ and ImportC:)
431+
432+
$(CCODE
433+
struct s { int a; };
434+
435+
void g(int s)
436+
{
437+
struct s* p = (struct s*)malloc(sizeof(struct s));
438+
p->a = s;
439+
}
440+
)
441+
442+
$(P Whereas this is rejected by both C++ and ImportC, for the same reason.)
443+
444+
$(CCODE
445+
struct s { int a; };
446+
447+
void g(int s)
448+
{
449+
s* p = (s*)malloc(sizeof(s));
450+
p->a = s;
451+
}
452+
)
423453

424454
$(H3 $(LNAME2 ctfe, Compile Time Function Execution))
425455

0 commit comments

Comments
 (0)