From 0e43f3aef401f87030a540646f061b025a5a130b Mon Sep 17 00:00:00 2001 From: grischka Date: Sun, 6 Apr 2014 10:59:40 +0200 Subject: [PATCH] win32: warn people about using undeclared WINAPI functions *** UNCONDITIONALLY *** Esp. sihce tinycc winapi headers are not as complete as people might expect this can otherwise lead to obscure problems that are difficult to debug. (Originally 'warn_implicit_function_declaration' was set to 1 always for windows but someone must have deleted that line) --- tccgen.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/tccgen.c b/tccgen.c index b698da9..e6e0fe1 100644 --- a/tccgen.c +++ b/tccgen.c @@ -3901,13 +3901,19 @@ ST_FUNC void unary(void) expect("identifier"); s = sym_find(t); if (!s) { + const char *name = get_tok_str(t, NULL); if (tok != '(') - tcc_error("'%s' undeclared", get_tok_str(t, NULL)); + tcc_error("'%s' undeclared", name); /* for simple function calls, we tolerate undeclared external reference to int() function */ - if (tcc_state->warn_implicit_function_declaration) - tcc_warning("implicit declaration of function '%s'", - get_tok_str(t, NULL)); + if (tcc_state->warn_implicit_function_declaration +#ifdef TCC_TARGET_PE + /* people must be warned about using undeclared WINAPI functions + (which usually start with uppercase letter) */ + || (name[0] >= 'A' && name[0] <= 'Z') +#endif + ) + tcc_warning("implicit declaration of function '%s'", name); s = external_global_sym(t, &func_old_type, 0); } if ((s->type.t & (VT_STATIC | VT_INLINE | VT_BTYPE)) ==