mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
Revert "cgen: fix all -Wmissing-variable-declarations (#5802)"
This reverts commit ae349ca6ba
.
Fixing these warnings, unfortunately also means, that hot code
(which reloads a shared library during runtime) can not use V
constants, because the private static C variables in the shared
library will not be initialized by _vinit(), which is only called
by the main V program.
For example in examples/hot_reload/bounce.v, using `gx.blue`,
defined as:
` blue = Color { r: 0, g: 0, b: 255 }`
... will instead use a const with all 0 fields (i.e. a black color).
This commit is contained in:
parent
937a3e14c5
commit
2f6757a56a
@ -879,7 +879,7 @@ fn (mut g Gen) stmt(node ast.Stmt) {
|
|||||||
}
|
}
|
||||||
ast.GlobalDecl {
|
ast.GlobalDecl {
|
||||||
styp := g.typ(node.typ)
|
styp := g.typ(node.typ)
|
||||||
g.definitions.writeln('static $styp $node.name; // global')
|
g.definitions.writeln('$styp $node.name; // global')
|
||||||
}
|
}
|
||||||
ast.GoStmt {
|
ast.GoStmt {
|
||||||
g.go_stmt(node)
|
g.go_stmt(node)
|
||||||
@ -3201,7 +3201,7 @@ fn (mut g Gen) const_decl(node ast.ConstDecl) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
ast.StringLiteral {
|
ast.StringLiteral {
|
||||||
g.definitions.writeln('static string _const_$name; // a string literal, inited later')
|
g.definitions.writeln('string _const_$name; // a string literal, inited later')
|
||||||
if g.pref.build_mode != .build_module {
|
if g.pref.build_mode != .build_module {
|
||||||
g.stringliterals.writeln('\t_const_$name = $val;')
|
g.stringliterals.writeln('\t_const_$name = $val;')
|
||||||
}
|
}
|
||||||
@ -3228,7 +3228,7 @@ fn (mut g Gen) const_decl_init_later(mod, name, val string, typ table.Type) {
|
|||||||
styp := g.typ(typ)
|
styp := g.typ(typ)
|
||||||
//
|
//
|
||||||
cname := '_const_$name'
|
cname := '_const_$name'
|
||||||
g.definitions.writeln('static $styp $cname; // inited later')
|
g.definitions.writeln('$styp $cname; // inited later')
|
||||||
g.inits[mod].writeln('\t$cname = $val;')
|
g.inits[mod].writeln('\t$cname = $val;')
|
||||||
if g.pref.autofree {
|
if g.pref.autofree {
|
||||||
if styp.starts_with('array_') {
|
if styp.starts_with('array_') {
|
||||||
|
@ -225,7 +225,7 @@ $c_common_macros
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// g_live_info is used by live.info()
|
// g_live_info is used by live.info()
|
||||||
static void* g_live_info = NULL;
|
void* g_live_info = NULL;
|
||||||
|
|
||||||
//============================== HELPER C MACROS =============================*/
|
//============================== HELPER C MACROS =============================*/
|
||||||
//#define tos4(s, slen) ((string){.str=(s), .len=(slen)})
|
//#define tos4(s, slen) ((string){.str=(s), .len=(slen)})
|
||||||
@ -265,7 +265,7 @@ static inline bool _us64_lt(uint64_t a, int64_t b) { return a < INT64_MAX && (in
|
|||||||
|
|
||||||
//================================== GLOBALS =================================*/
|
//================================== GLOBALS =================================*/
|
||||||
//byte g_str_buf[1024];
|
//byte g_str_buf[1024];
|
||||||
static byte* g_str_buf;
|
byte* g_str_buf;
|
||||||
int load_so(byteptr);
|
int load_so(byteptr);
|
||||||
void reload_so();
|
void reload_so();
|
||||||
void _vinit();
|
void _vinit();
|
||||||
|
Loading…
Reference in New Issue
Block a user