diff --git a/ROADMAP.md b/ROADMAP.md index 485edfc919..8fbaf368ee 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -10,7 +10,7 @@ - [ ] Recursive structs via optionals: `struct Node { next ?Node }` - [ ] Handle function pointers safely, remove `if function == 0 {` - [ ] Bundle OpenSSL like GC -- [ ] Anonymous structs +- [x] Anonymous structs - [ ] -usecache on by default - [ ] -skip-unused on by default diff --git a/vlib/v/checker/checker.v b/vlib/v/checker/checker.v index dd9940bda9..2683f9bbcc 100644 --- a/vlib/v/checker/checker.v +++ b/vlib/v/checker/checker.v @@ -1900,7 +1900,13 @@ fn (mut c Checker) hash_stmt(mut node ast.HashStmt) { } } else { - if node.kind != 'define' { + if node.kind == 'define' { + if !c.is_builtin_mod && !c.file.path.ends_with('.c.v') + && !c.file.path.contains('vlib/') { + c.error("#define can only be used in vlib (V's standard library) and *.c.v files", + node.pos) + } + } else { c.error('expected `#define`, `#flag`, `#include`, `#insert` or `#pkgconfig` not $node.val', node.pos) }