[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: const char* typedefs
- From: Tim Hill <drtimhill@...>
- Date: Mon, 5 Feb 2018 21:00:58 -0800
> On Feb 5, 2018, at 8:00 PM, nobody <nobody+lua-list@afra-berlin.de> wrote:
>
> On 2018-02-05 23:50, Paige DePol wrote:
>> They also like putting the * for pointers on the variable name, which
>> is what Lua does as well. My previous experience with Obj-C usually
>> put the * with the type, which makes more sense to me, but I am now
>> used to putting it with the var name so either way works.
>
> That's because in C
>
> Foo* bar, baz;
>
> probably isn't what you want[1], and with
>
> Foo *bar, baz;
>
> it's easier to notice.
>
> -- nobody
>
> [1] bar is a pointer, baz isn't.
>
Which is an argument in favor of the typedef, since:
typedef const char *l_str;
l_str bar, baz;
DOES work correctly.
—Tim