News for hackers. Stuff that matters.
Re:Tips on writing C macros by paulbaumgart on Tuesday August 04, 2009 @08:52PM (#742559)
typeof 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).

There are no comments on this comment yet.