[Mesa-dev] [PATCH 1/7] glcpp: Add support for __LINE__ and __FILE__ macros

Matt Turner mattst88 at gmail.com
Thu Nov 29 10:59:05 PST 2012


On Thu, Nov 29, 2012 at 10:38 AM, Carl Worth <cworth at cworth.org> wrote:
> Matt Turner <mattst88 at gmail.com> writes:
>> #line __LINE__
>> __LINE__
>> #line __LINE__
>> __LINE__
>>
>> when run through glcpp emits this:
>>
>> #line 1
>> 1
>> #line 2
>> 2
>
> That looks absolutely correct to me, (if very strange to ever do "#line
> __LINE__"). For example, this matches the behavior of "gcc -E -" on the
> same example.
>

Huh, you're right. (#line __LINE__ is indeed weird, so the only reason
you might do that would be in #line __LINE__ "filename" where you
really only cared about setting the filename.)

> For "normal" uses of #line, this is what you want. The #line directive
> specifies what line number the compiler should use for the subsequent
> line of code, (which is useful for getting error messages that point to
> the original source when the compiler is actually chewing on some
> generated code derived from that source).

Series is Reviewed-by: Matt Turner <mattst88 at gmail.com>


More information about the mesa-dev mailing list