R
rkk
Hi,
Is there an equivalent typeof macro/method to determine the type of a
variable in runtime & most importantly that works well with most known
C compilers?
gcc compiler supports typeof() macro, but the same code is not getting
compiled in solaris forte compiler and in microsoft VS 2003 compiler. I
tried something like below:
#include <stdio.h>
int
main()
{
int i;
typeof(i) j = 10;
i = j + 1;
printf("%d,%d\n",i,j);
return 0;
}
The above code is just a test to see if the compiler supports typeof
macro/method. But only gcc supports it. I then tried __typeof__ which
is described in ISO standards I hope (I'm not sure btw), but again
supported by gcc and not by other compilers.
How does this typeof macro work? Or is there any equivalent
method/macro which is portable or that can be made portable to work
with all well known compilers.
Thanks in advance.
Best Regards
RKK
Is there an equivalent typeof macro/method to determine the type of a
variable in runtime & most importantly that works well with most known
C compilers?
gcc compiler supports typeof() macro, but the same code is not getting
compiled in solaris forte compiler and in microsoft VS 2003 compiler. I
tried something like below:
#include <stdio.h>
int
main()
{
int i;
typeof(i) j = 10;
i = j + 1;
printf("%d,%d\n",i,j);
return 0;
}
The above code is just a test to see if the compiler supports typeof
macro/method. But only gcc supports it. I then tried __typeof__ which
is described in ISO standards I hope (I'm not sure btw), but again
supported by gcc and not by other compilers.
How does this typeof macro work? Or is there any equivalent
method/macro which is portable or that can be made portable to work
with all well known compilers.
Thanks in advance.
Best Regards
RKK