[Mesa-dev] [PATCH 3/3] glcpp: Define dummy __LINE__ and __FILE__ macros

Matt Turner mattst88 at gmail.com
Mon Nov 26 14:30:19 PST 2012


This is at least better than failing to compile the shader.

I think this is a pretty clear indication that app developers think
these macros are about as useful as the rest of us.

Works around es3conform's silly preprocess2_frag and preprocess16_frag
tests.
---
 src/glsl/glcpp/README        |    4 ++--
 src/glsl/glcpp/glcpp-parse.y |    3 +++
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/glsl/glcpp/README b/src/glsl/glcpp/README
index 0b5ef50..592d073 100644
--- a/src/glsl/glcpp/README
+++ b/src/glsl/glcpp/README
@@ -25,8 +25,8 @@ and will not appear in the output.
 
 Known limitations
 -----------------
-The __LINE__ and __FILE__ macros are not yet supported.
+The __LINE__ and __FILE__ macros always evaluate to zero.
 
 A file that ends with a function-like macro name as the last
 non-whitespace token will result in a parse error, (where it should be
-passed through as is).
\ No newline at end of file
+passed through as is).
diff --git a/src/glsl/glcpp/glcpp-parse.y b/src/glsl/glcpp/glcpp-parse.y
index f62cbe4..e09de94 100644
--- a/src/glsl/glcpp/glcpp-parse.y
+++ b/src/glsl/glcpp/glcpp-parse.y
@@ -1186,6 +1186,9 @@ glcpp_parser_create (const struct gl_extensions *extensions, int api)
 
 	language_version = 110;
 	add_builtin_define(parser, "__VERSION__", language_version);
+	/* FINISHME */
+	add_builtin_define(parser, "__FILE__", 0);
+	add_builtin_define(parser, "__LINE__", 0);
 
 	return parser;
 }
-- 
1.7.8.6



More information about the mesa-dev mailing list