ANSI C和函数重载

Ami*_*yan 6 c naming overloading

可能重复:
C中的函数重载

ANSI C不允许函数重载(我不确定C99).

例如:

char  max(char  x, char  y);
short max(short x, short y);
int   max(int   x, int   y);
float max(float x, float y);
Run Code Online (Sandbox Code Playgroud)

不是有效的ANSI C源代码.

ANSI C中的函数重载问题应该使用哪种技术(或想法)?

注意:

答案是重命名函数,但应该使用哪种模式进行重命名,函数名称仍然是"良好的函数名称"

例如:

char  max1(char  x, char  y);
short max2(short x, short y);
int   max3(int   x, int   y);
float max4(float x, float y);
Run Code Online (Sandbox Code Playgroud)

对于函数名称来说不是一个好的命名max.

vic*_*azo 11

例如,使用要在函数名称中计算的数据类型

char  max_char(char  x, char  y);
short max_short(short x, short y);
int   max_int(int   x, int   y);
float max_float(float x, float y);
Run Code Online (Sandbox Code Playgroud)