我想提供一种元素作为参数的类型的指针数组的初始化一个未知的类型的元件typeof的返回类型是什么?
类似
void* init(type t)
void* array = malloc(sizeof_type(t)*10));
return array;
}
和以后调用例如
init(typeof(int))
但我无法确定typeof的返回类型是什么。
我想可以用
malloc((type) 0);
在此先感谢
PS可以实现sizeof_type想:这如果一个矢量implementatin如果有人能指出我的一些flexiblecode我将非常感激,以及
这应该是重新标记,这看起来并不像C在所有 – 2010-07-16 14:11:40
也许这将帮助:http://www.redhat.com/docs/manuals/enterprise/RHEL-4-Manual/gcc/typeof.html也可能是这样的:http://www.accu-usa.org /Listings/2000-05-Listing01.html – FrustratedWithFormsDesigner 2010-07-16 14:12:49
我会非常谨慎的使用typeof(),除非我确定我希望我的程序只能在GNU上工作。 – Uri 2010-07-16 14:15:08