[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [RFC] Framebuffer rotation patch
From: |
Michal Suchanek |
Subject: |
Re: [RFC] Framebuffer rotation patch |
Date: |
Wed, 17 Feb 2010 00:19:59 +0100 |
On 16 February 2010 22:14, address@hidden
<address@hidden> wrote:
> On Tue, Feb 16, 2010 at 3:05 PM, Michal Suchanek <address@hidden> wrote:
>> 2010/2/16 Vladimir 'φ-coder/phcoder' Serbinenko <address@hidden>:
>>> Michal Suchanek wrote:
>>>>> With typeof macro this can be made type-neutral avoiding potential
>>>>> mistakes.
>>>>> +static inline long
>>>>> +grub_min (long x, long y)
>>>>> +{
>>>>> + if (x > y)
>>>>> + return y;
>>>>> + else
>>>>> + return x;
>>>>> +}
>>>>> +
>>>>>
>>>>
>>>> I don't see how typeof would be used. As I understand the docs it can
>>>> only set types relative to something what is already defined (and in
>>>> some cases actually dereference/call it) and there is nothing defined
>>>> at the point these functions are declared to copy the type from.
>>>>
>>> #include <stdio.h>
>>> #define swap(a,b) {typeof (a) mytemp ## __LINE__; mytemp ## __LINE__ =
>>> b; b = a; a = mytemp ## __LINE__; }
>>>
>>
>> Unlike inlines this pollutes the local namespace with unexpected
>> identifiers.. Perhaps the temporary variable should be at least
>> prefixed with an underscore or something.
>
> The braces introduce a block and the variable goes out of scope, in
> fact there's no need for __LINE__ because of this.
It breaks things when you do have a mytemp already:
$ gcc -Wall testdef.c
$ ./a.out
2 1 3 4
$ cat testdef.c
#include <stdio.h>
#define swap(a,b) {typeof (a) mytemp; mytemp = b; b = a; a = mytemp; }
int main( int argc, char ** argv)
{
int x=1, y=2, z=3, mytemp=4;
swap(x,y);
swap(z,mytemp);
return printf("%i %i %i %i\n", x, y, z, mytemp);
}
Thanks
Michal
- Re: [RFC] Framebuffer rotation patch, or why 'unsigned' fails us, (continued)
- Re: [RFC] Framebuffer rotation patch, or why 'unsigned' fails us, Michal Suchanek, 2010/02/16
- Re: [RFC] Framebuffer rotation patch, Vladimir 'φ-coder/phcoder' Serbinenko, 2010/02/16
- Re: [RFC] Framebuffer rotation patch, Michal Suchanek, 2010/02/16
- Re: [RFC] Framebuffer rotation patch, Isaac Dupree, 2010/02/16
- Re: [RFC] Framebuffer rotation patch, address@hidden, 2010/02/16
- [Off-topic] C++ enums, Isaac Dupree, 2010/02/16
Re: [RFC] Framebuffer rotation patch, Michal Suchanek, 2010/02/16