1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

checker: do not allow #define everywhere

This commit is contained in:
Alexander Medvednikov 2022-07-10 22:51:02 +03:00
parent 235ef23588
commit 22dac71b33
2 changed files with 8 additions and 2 deletions

View File

@ -10,7 +10,7 @@
- [ ] Recursive structs via optionals: `struct Node { next ?Node }` - [ ] Recursive structs via optionals: `struct Node { next ?Node }`
- [ ] Handle function pointers safely, remove `if function == 0 {` - [ ] Handle function pointers safely, remove `if function == 0 {`
- [ ] Bundle OpenSSL like GC - [ ] Bundle OpenSSL like GC
- [ ] Anonymous structs - [x] Anonymous structs
- [ ] -usecache on by default - [ ] -usecache on by default
- [ ] -skip-unused on by default - [ ] -skip-unused on by default

View File

@ -1900,7 +1900,13 @@ fn (mut c Checker) hash_stmt(mut node ast.HashStmt) {
} }
} }
else { 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', c.error('expected `#define`, `#flag`, `#include`, `#insert` or `#pkgconfig` not $node.val',
node.pos) node.pos)
} }