mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
remove #ifdef, #ifndef, etc
This commit is contained in:
@ -2627,48 +2627,18 @@ fn (p mut Parser) chash() {
|
||||
p.genln('#include $file')
|
||||
}
|
||||
}
|
||||
else if is_c_pre(hash) {
|
||||
// Skip not current OS hack
|
||||
if hash.starts_with('ifdef') {
|
||||
os := hash.right(6).trim_space()
|
||||
// println('ifdef "$os" $p.scanner.line_nr')
|
||||
if os == 'linux' && p.os != LINUX {
|
||||
// println('linux ifdef skip')
|
||||
for p.tok != EOF {
|
||||
if p.tok == HASH && p.lit.contains('else') || p.lit.contains('endif') {
|
||||
break
|
||||
}
|
||||
// println('skipping')
|
||||
p.next()
|
||||
}
|
||||
}
|
||||
}
|
||||
// Move defines on top (like old gdefine)
|
||||
if hash.contains('define') {
|
||||
p.cgen.includes << '#$hash'
|
||||
}
|
||||
else {
|
||||
p.genln('#$hash')
|
||||
}
|
||||
else if hash.contains('define') {
|
||||
// Move defines on top
|
||||
p.cgen.includes << '#$hash'
|
||||
}
|
||||
else {
|
||||
if !p.can_chash {
|
||||
p.error('bad token `#` (embedding C code is no longer supported)')
|
||||
}
|
||||
//println('HASH!!! $p.file_name $p.scanner.line_nr')
|
||||
if p.cur_fn.name == '' {
|
||||
// p.error('# outside of fn')
|
||||
}
|
||||
p.genln(hash)
|
||||
}
|
||||
}
|
||||
|
||||
fn is_c_pre(hash string) bool {
|
||||
return hash.contains('ifdef') || hash.contains('define') ||
|
||||
hash.contains('endif') || hash.contains('elif') ||
|
||||
hash.contains('ifndef') || (hash.contains('else') && !hash.contains('{'))
|
||||
}
|
||||
|
||||
fn (p mut Parser) if_st(is_expr bool) string {
|
||||
if is_expr {
|
||||
if p.fileis('if_expr') {
|
||||
|
Reference in New Issue
Block a user