[Mesa-dev] [PATCH] fix compilation of glsl_lexer.ll with msvc

Morgan Armand morgan.devel at gmail.com
Sat Oct 29 06:46:19 PDT 2011


On 10/29/2011 11:50 AM, Kenneth Graunke wrote:
> On 10/29/2011 01:42 AM, Morgan Armand wrote:
>> strtoull is not supported on msvc (as there is no C99 support).
>>
>> ---
>>  src/glsl/glsl_lexer.ll |    4 ++++
>>  1 files changed, 4 insertions(+), 0 deletions(-)
>>
>> diff --git a/src/glsl/glsl_lexer.ll b/src/glsl/glsl_lexer.ll
>> index e444536..00065d5 100644
>> --- a/src/glsl/glsl_lexer.ll
>> +++ b/src/glsl/glsl_lexer.ll
>> @@ -93,7 +93,11 @@ literal_integer(char *text, int len, struct
>> _mesa_glsl_parse_state *state,
>>     if (base == 16)
>>        digits += 2;
>>  
>> +#ifdef _MSC_VER
>> +   __int64 value = _strtoui64(digits, NULL, base);
>
> Presumably this should be "unsigned __int64" to match the code below?
Yes, you're right.
>
>> +#else
>>     unsigned long long value = strtoull(digits, NULL, base);
>> +#endif
>>  
>>     lval->n = (int)value;
>
> I kind of wish we just had c99.c/c99.h files with #ifdef MSVC guards
> that defined the necessary missing C99 functions, with their normal
> names and arguments, in terms of their MSVC equivalent.  Then we
> wouldn't need to litter the code with workarounds.
>
> Though, that's something for a later time.
Sounds like a good idea too! Here is the corrected (and hopefully not
wrapped) patch.

---
 src/glsl/glsl_lexer.ll |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/src/glsl/glsl_lexer.ll b/src/glsl/glsl_lexer.ll
index e444536..5364841 100644
--- a/src/glsl/glsl_lexer.ll
+++ b/src/glsl/glsl_lexer.ll
@@ -93,7 +93,11 @@ literal_integer(char *text, int len, struct
_mesa_glsl_parse_state *state,
    if (base == 16)
       digits += 2;
 
+#ifdef _MSC_VER
+   unsigned __int64 value = _strtoui64(digits, NULL, base);
+#else
    unsigned long long value = strtoull(digits, NULL, base);
+#endif
 
    lval->n = (int)value;
 
-- 
1.7.7.1.msysgit.0



More information about the mesa-dev mailing list