Posted By: Fenriswolf
Function overloading - 08/20/08 15:51
Hello,
in Lite-C (A7.10.1) function overloading does not work properly when the respective function takes a pointer as an argument (or so it seems; apparently there is a relation).
Here is the thread that led to this conlusion.
Example:
The following code works without any problems:
However, when a pointer is added to the overloaded function as a second argument, overloading doesn't work anymore.
In the following example the first function prototype is always used, leading to a crash. (typecast doesn't help)
in Lite-C (A7.10.1) function overloading does not work properly when the respective function takes a pointer as an argument (or so it seems; apparently there is a relation).
Here is the thread that led to this conlusion.
Example:
The following code works without any problems:
Code:
int test (char* s); int test (int n); void main () { int num = 5; char* str = "4"; printf("%i", test(num)); //return 5 printf("%i", test(str)); //return 4 } int test(char* s) { return ((int)str_to_num(s)); } int test(int n) { return n; }
However, when a pointer is added to the overloaded function as a second argument, overloading doesn't work anymore.
In the following example the first function prototype is always used, leading to a crash. (typecast doesn't help)
Code:
int test (char* s, int *i); int test (int n, int *i); void main () { int num = 5; char* str = "4"; printf("%i", test(num, NULL)); //return 5 (this will crash) printf("%i", test(str, NULL)); //return 4 } int test(char* s, int *i) { return ((int)str_to_num(s)); } int test(int n, int *i) { return n; }