------- Comment #6 from raeburn at raeburn dot org 2007-08-29 11:12 ------- (In reply to comment #5) > I don't understand the error !! It's all so simple and I don't understand > why the compile works if I write in the second form (not inline parameter > declaration) !!!
(This would be more suitable for the gcc-help list, btw...) The bit about a type with default promotions refers to the fact that if there isn't a prototype declaration (or a prototype style function definition) in scope for the function, then integral arguments narrower than "int" get "promoted" to "int" in the function signature, and that's how the argument gets passed. (And "float" would become "double" as well.) Your second ("not inline") version uses a non-prototype style definition, so the passed argument type is in fact an "int". In the first version of your code, the function is called with no declaration in scope, so it's assumed that all argument types are the result of the default promotions, and then you declare it as taking a "char" not promoted to "int", which conflicts with the previous assumption. (The use of a function without a prototype in scope also causes the compiler to assume that it takes a fixed number of arguments, not a variable number of arguments like printf; gcc knows that printf takes a variable number of arguments, but warns you about it because according to the semantics of the C language, your source file is still requiring that printf be a non-variable-argument function. While on many platforms that won't cause you problems, on some it will; sometimes variable argument lists get passed differently from fixed argument lists.) I know it seems a bit odd; I think it's come to be this way mostly because of a combination of factors in the standardization process, mainly trying to allow really old C code (from before there was a language standard in 1989) to work as it was, and to allow compilers to get good performance out of modern code (using prototypes and such introduced with the 1989 standard). In short, if you want to use non-promoted types in your argument lists, you should make sure you've got prototypes in scope before the function gets referenced. Stick "int a(char);" at the top of the first version and it should work fine. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33219