3 ms·
Excuse my lack of C knowledge, but using your proposed macro, what would be the result of calling: MYMACRO(x,y,x+y) with your inclusion of typeof()?
by greyboy 17y ago
Excuse my lack of C knowledge, but using your proposed macro, what would be the result of calling:
MYMACRO(x,y,x+y)
with your inclusion of typeof()?
- paulbaumgart 17y agotypeof is pretty smart. Since in C all types are known at compile-time, the compiler can put in there in whatever type typeof's parameter resolves to- even if it's an expression. As an example: int main () { typeof (1.0f + 10) a; int * b = &a; } ----- $ g++ test.c test.c: In function ‘int main()’: test.c:3: error: cannot convert ‘float*’ to ‘int*’ in initialization I'm using g++ because it actually spits out type information for incompatible pointers- probably something having to do with it being an error in C++ but valid in C (with a warning, at least in GCC).