aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgrischka <grischka>2014-04-06 10:59:40 +0200
committergrischka <grischka>2014-04-06 10:59:40 +0200
commit0e43f3aef401f87030a540646f061b025a5a130b (patch)
tree65af4f591d487ad013f40104b8b3ad3d89b6e7ff
parent6a947d9d2610723db3f46bcae4f35d5d5c572f89 (diff)
downloadtinycc-0e43f3aef401f87030a540646f061b025a5a130b.tar.gz
tinycc-0e43f3aef401f87030a540646f061b025a5a130b.tar.bz2
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)
-rw-r--r--tccgen.c14
1 files 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)) ==