File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments