Bug 85918

Summary: Mesa: MSVC 2010/2012 Compile error
Product: Mesa Reporter: Michael Bachmann <mr.bachmann>
Component: Mesa coreAssignee: mesa-dev
Status: RESOLVED FIXED QA Contact:
Severity: blocker    
Priority: medium    
Version: 10.3   
Hardware: x86-64 (AMD64)   
OS: Windows (All)   
Whiteboard:
i915 platform: i915 features:
Attachments: patch for the file src/mesa/main/macros.h

Description Michael Bachmann 2014-11-05 15:08:04 UTC
Created attachment 108965 [details]
patch for the file src/mesa/main/macros.h

To reproduce:

- I setup a working environment for compiling mesa on windows following a description which can be found here:

https://sites.google.com/site/buildllvmpipe/

I used MesaLib-10.3.2 and llvm-3.4.2 for building opengl32.dll.

when finally compiling mesa, the following error occurs:
-------------------------------------------------------------------------------
  Compiling src\mesa\drivers\windows\gdi\wmesa.c ...
wmesa.c
  Compiling src\mesa\main\api_arrayelt.c ...
src\mesa\drivers\windows\gdi\wmesa.c(278) : error C2059: syntax error : 'bad suffix on number'
src\mesa\drivers\windows\gdi\wmesa.c(278) : error C2146: syntax error : missing ')' before identifier 'color'
src\mesa\drivers\windows\gdi\wmesa.c(278) : error C2059: syntax error : 'bad suffix on number'
src\mesa\drivers\windows\gdi\wmesa.c(278) : error C2059: syntax error : ')'
src\mesa\drivers\windows\gdi\wmesa.c(278) : error C2059: syntax error : 'bad suffix on number'
src\mesa\drivers\windows\gdi\wmesa.c(279) : error C2059: syntax error : 'bad suffix on number'
src\mesa\drivers\windows\gdi\wmesa.c(279) : error C2146: syntax error : missing ')' before identifier 'color'
src\mesa\drivers\windows\gdi\wmesa.c(279) : error C2059: syntax error : 'bad suffix on number'
src\mesa\drivers\windows\gdi\wmesa.c(279) : error C2059: syntax error : ')'
src\mesa\drivers\windows\gdi\wmesa.c(279) : error C2059: syntax error : 'bad suffix on number'
src\mesa\drivers\windows\gdi\wmesa.c(280) : error C2059: syntax error : 'bad suffix on number'
src\mesa\drivers\windows\gdi\wmesa.c(280) : error C2146: syntax error : missing ')' before identifier 'color'
src\mesa\drivers\windows\gdi\wmesa.c(280) : error C2059: syntax error : 'bad suffix on number'
src\mesa\drivers\windows\gdi\wmesa.c(280) : error C2059: syntax error : ')'
src\mesa\drivers\windows\gdi\wmesa.c(280) : error C2059: syntax error : 'bad suffix on number'
api_arrayelt.c
  Compiling build\windows-x86_64\mesa\main\api_exec.c ...
scons: *** [build\windows-x86_64\mesa\drivers\windows\gdi\wmesa.obj] Error 2
  Compiling src\mesa\main\api_loopback.c ...
api_exec.c
api_loopback.c
scons: building terminated because of errors.
-------------------------------------------------------------------------------

The problem is to be found in the Macros UNCLAMPED_FLOAT_TO_UBYTE and CLAMPED_FLOAT_TO_UBYTE.

These macros have a parameter named 'F' which the compiler uses to replace the number suffix e.g. the 'F' at the end of '255.0F'.

Find attached a patch which allows to compile the code with Visual Studio 2010 and 2012, where the Macro parameter 'F' has simply been renamed to 'FL'.
Comment 1 Roland Scheidegger 2014-11-05 15:32:13 UTC
This was already fixed on mesa master in a similar fashion quite a while ago - commit 9608193cbc6ea14e49adcd0193f9e7c6058d5a2f. I guess we forgot about nominating it for 10.3 branch, I'm going to do that now.
Comment 2 Emil Velikov 2014-11-05 15:58:16 UTC
Roland,
Can we encourage "newcomers" to use MSVC 2013 and later (if ever available) ? This way once you guys (and others) are over to 2013 we can just go with - anything prior to MSVC2013 is not supported :P
I.e. having a gradual transition period is always a nice.
Comment 3 Roland Scheidegger 2014-11-05 17:03:34 UTC
(In reply to Emil Velikov from comment #2)
> Roland,
> Can we encourage "newcomers" to use MSVC 2013 and later (if ever available)
> ? This way once you guys (and others) are over to 2013 we can just go with -
> anything prior to MSVC2013 is not supported :P
> I.e. having a gradual transition period is always a nice.

I don't think this particular bug is actually dependent on msvc version (it is, however, dependent on release vs. debug build). But in general I don't have anything against recommending newer msvc versions.
Comment 4 Emil Velikov 2014-11-06 15:09:49 UTC
Roland,
Indeed this issue is not related (does not seem) to the verison of msvc yet it's a nice reminder about the topic, plus an humble ping for Michael :)
Comment 5 Emil Velikov 2014-11-06 15:10:46 UTC
Pushed to the 10.3 branch. Issue will be fixed in mesa 10.3.3.

commit d5700dc276008decb2a5d63bfa38522c5f4ad3f3
Author: Brian Paul <brianp@vmware.com>
Date:   Wed Sep 10 08:16:24 2014 -0600

    mesa: fix UNCLAMPED_FLOAT_TO_UBYTE() macro for MSVC

    MSVC replaces the "F" in "255.0F" with the macro argument which leads
    to an error.  s/F/FLT/ to avoid that.

    It turns out we weren't using this macro at all on MSVC until the
    recent "mesa: Drop USE_IEEE define." change.

    Reviewed-by: Roland Scheidegger <sroland@vmware.com>
    (cherry picked from commit 9608193cbc6ea14e49adcd0193f9e7c6058d5a2f)
    Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=85918
    Nominated-by: Roland Scheidegger <sroland@vmware.com>
Comment 6 Michael Bachmann 2014-11-06 15:39:59 UTC
Thank you for taking care about this issue and for including the fix in Version 10.3.3.
Comment 7 Jose Fonseca 2014-11-07 11:26:17 UTC
(In reply to Emil Velikov from comment #2)
> Roland,
> Can we encourage "newcomers" to use MSVC 2013 and later (if ever available)
> ? This way once you guys (and others) are over to 2013 we can just go with -
> anything prior to MSVC2013 is not supported :P
> I.e. having a gradual transition period is always a nice.

I'm afraid VMware needs to build with MSVC 2012.  See explanation on 
http://lists.freedesktop.org/archives/piglit/2014-October/013129.html

It's OK recommending MSVC 2013, but we need to continue to support MSVC 2012 a bit longer.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.