user-0 提问: 如果函数返回类型不确定，最终的值会是什么？

回复:
user: user-1
content: 调用约定 https://msdn.microsoft.com/zh-cn/magazine/9b372w95.aspx

user: user-2
content: 返回值与return 后面的类型不一致时会隐式转换，但函数返回的类型是一致的，1楼大牛解释地很好了

user: user-3
content: 不存在类型不确定的可能

user: user-4
content: 你的函数返回类型是确定的，是 unsingned char 。  C 不会有返回类型不确定的函数。  ===================================== 7.19.6.3 The printf function Synopsis 1 #include <stdio.h> int printf(const char * restrict format, ...); Description 2 The printf function is equivalent to fprintf with the argument stdout interposed before the arguments to printf.  ============================= 7.19.6.1 The fprintf function 8 The conversion specifiers and their meanings are: d,i The int argument is converted to signed decimal in the style [−]dddd. The precision specifies the minimum number of digits to appear; if the value being converted can be represented in fewer digits, it is expanded with leading zeros. The default precision is 1. The result of converting a zero value with a precision of zero is no characters.  9 If a conversion specification is invalid, the behavior is undefined.239) If any argument is not the correct type for the corresponding conversion specification, the behavior is undefined.  ====================================== The behavior is undefined  未定义行为

user: user-4
content: 引用 5 楼 warcraftzhaochen 的回复:[quote=引用 1 楼 user-4 的回复:] 你的函数返回类型是确定的，是 unsingned char 。  C 不会有返回类型不确定的函数。  ===================================== 7.19.6.3 The printf function Synopsis 1 #include <stdio.h> int printf(const char * restrict format, ...); Description 2 The printf function is equivalent to fprintf with the argument stdout interposed before the arguments to printf.  ============================= 7.19.6.1 The fprintf function 8 The conversion specifiers and their meanings are: d,i The int argument is converted to signed decimal in the style [−]dddd. The precision specifies the minimum number of digits to appear; if the value being converted can be represented in fewer digits, it is expanded with leading zeros. The default precision is 1. The result of converting a zero value with a precision of zero is no characters.  9 If a conversion specification is invalid, the behavior is undefined.239) If any argument is not the correct type for the corresponding conversion specification, the behavior is undefined.  ====================================== The behavior is undefined  未定义行为       实际问题是这样的 调用fun的和fun不属于同一个文件，且没有引用fun的声明，在vs2008中发现这种现象 unsigned int a = fun();                  //a 不正常 unsigned char b = fun();              //  b正常 但在arm编译器中却都正常 [/quote]  你要问 C99 的话，这应该是一个编译错误。 C99 已经不允许使用未经声明的函数。 =========== C89 的话，这个可以，会有一个默认的声明 int fun() 。注意这里返回值类型也是确定的（int），而不是不确定。  同时，当调用是的声明（int func()）与定义是的声明（unsinged char func()）不一致的时候，依然是一个未定义行为。

user: user-0
content: 引用 1 楼 user-4 的回复:你的函数返回类型是确定的，是 unsingned char 。  C 不会有返回类型不确定的函数。  ===================================== 7.19.6.3 The printf function Synopsis 1 #include <stdio.h> int printf(const char * restrict format, ...); Description 2 The printf function is equivalent to fprintf with the argument stdout interposed before the arguments to printf.  ============================= 7.19.6.1 The fprintf function 8 The conversion specifiers and their meanings are: d,i The int argument is converted to signed decimal in the style [−]dddd. The precision specifies the minimum number of digits to appear; if the value being converted can be represented in fewer digits, it is expanded with leading zeros. The default precision is 1. The result of converting a zero value with a precision of zero is no characters.  9 If a conversion specification is invalid, the behavior is undefined.239) If any argument is not the correct type for the corresponding conversion specification, the behavior is undefined.  ====================================== The behavior is undefined  未定义行为       实际问题是这样的 调用fun的和fun不属于同一个文件，且没有引用fun的声明，在vs2008中发现这种现象 unsigned int a = fun();                  //a 不正常 unsigned char b = fun();              //  b正常 但在arm编译器中却都正常