[cfe-dev] some newbie questions

Douglas Gregor dgregor at apple.com
Tue Oct 13 17:54:08 PDT 2009


On Oct 13, 2009, at 10:19 AM, Jochen Wilhelmy <j.wilhelmy at arcor.de>  
wrote:

> Hi!
>
> I hope this is the right way to ask some newbie-questions about clang.
>
> 1. which option (clang::LangOptions) controls the overloading feature?
> (e.g. int foo(int x); int foo(float x);)
> is it possible to create a c-compiler with just overloading enabled
> additionally?

There is no specific LangOptions flag for overloading, although of  
course it is available whe CPlusPlus is set.

That said, there is an "overloadable" attribute that permits  
overloading in C. It is documented on Clang's language extensions web  
page, and is used by C99's <tgmath.h> and OpenCL.

> 2. do I have to typedef vector types myself also in x=cl mode?
> (e.g. typedef __attribute__(( ext_vector_type(4) )) float float4;)

Yes.

> 3. how to I create a vector type in a expression? I want to write
> a = b * float4(1, 2, 3, 4);
> I get error: function-style cast to a builtin type can only take one
> argument.
> Where can I patch this and would a patch be welcome or has it some
> reason that it does not work?

Put parentheses around "float4"?

> 4. how can I control the size of the builtin types (int, long etc.)?
> I want to set long to 64 bit independent of the target architecture.

I think you either have to pick an architecure with 64-bit longs or  
create your own variant of an similar architecture (then override the  
size of long).

   - Doug



More information about the cfe-dev mailing list