However I don't take an error with real function instead of a macro as we said before
Code:
#include<stdio.h>
int main(void)
{
int f1(int x , int y)
{
return x > y ? x : y;
}
printf("The biggest is : %d" , f1(2 , 4));
return 0;
}
It works by chance???
Anyway
Let's fix the previous problem with macro ...
Code:
#include<stdio.h>
#define GENERIC_MAX(type) \
type type##_max(type x, type y) \
{ \
return x > y ? x : y; \
}
int main(void)
{
return 0;
}
GENERIC_MAX(signed int);
GENERIC_MAX(long int);
GENERIC_MAX(unsigned long);
My question now is why I take 2 errors and not 3 errors.
Code:
tests.cpp:13: error: duplicate ‘signed’
Code:
tests.cpp:15: error: duplicate ‘unsigned’
long int parameter has 2 words.... the expansion would be :
Code:
signed int signed int_max(signed int x, signed int y) { return x > y ? x : y; };
long int long int_max(long int x, long int y) { return x > y ? x : y; };
unsigned long unsigned long_max(unsigned long x, unsigned long y) { return x > y ? x : y; };
long int long int_max ???? why does not produce an error (which is based that the type consist of two reserved words not only one for example int or float or something like that).
Thank you very much for the detailed answers