[Mesa-dev] [PATCH 01/15] glsl: Add __FILE__ and __LINE__ as built-in macros
anuj.phogat at gmail.com
Sat Jun 7 19:14:01 PDT 2014
On Fri, Jun 6, 2014 at 9:03 PM, Matt Turner <mattst88 at gmail.com> wrote:
> On Fri, Jun 6, 2014 at 4:56 PM, Anuj Phogat <anuj.phogat at gmail.com> wrote:
>> A compile error will be generated for redefinition of these macros.
>> Cc: <mesa-stable at lists.freedesktop.org>
>> Signed-off-by: Anuj Phogat <anuj.phogat at gmail.com>
>> src/glsl/glcpp/glcpp-parse.y | 2 ++
>> 1 file changed, 2 insertions(+)
>> diff --git a/src/glsl/glcpp/glcpp-parse.y b/src/glsl/glcpp/glcpp-parse.y
>> index 9887583..2ddc8b9 100644
>> --- a/src/glsl/glcpp/glcpp-parse.y
>> +++ b/src/glsl/glcpp/glcpp-parse.y
>> @@ -2053,6 +2053,8 @@ _glcpp_parser_handle_version_declaration(glcpp_parser_t *parser, intmax_t versio
>> parser->version_resolved = true;
>> + add_builtin_define (parser, "__FILE__", version);
>> + add_builtin_define (parser, "__LINE__", version);
> In order to give an error on redefinition of these, we define them to
> something meaningless, i.e., version?
oops. This was a copy-paste error and it worked so never got caught.
> I guess that works, since we have special handling of their expansion.
> Wouldn't it be better to handle them specially like we do in patch #2?
Yes. I'll drop this patch.
>> add_builtin_define (parser, "__VERSION__", version);
More information about the mesa-dev