Bug 35131

Summary: Cannot build in MSVC++ 2010
Product: cairo Reporter: Milan Crha <mcrha>
Component: generalAssignee: Carl Worth <cworth>
Status: RESOLVED WORKSFORME QA Contact: cairo-bugs mailing list <cairo-bugs>
Severity: critical    
Priority: medium    
Version: 1.10.2   
Hardware: x86 (IA32)   
OS: Windows (All)   
Whiteboard:
i915 platform: i915 features:

Description Milan Crha 2011-03-08 22:42:02 UTC
I tried to build cairo 1.10.2 under Microsoft Visual C++ 2010 (10.0) and the build fails in cairo.c with the below error. Considering the usage of that macro, and that's mostly unused, even in MSVC when compiled for 64bit, then I would like to suggest you to remove the macro completely. Thanks in advance.

Please note also those cairo-wideint-private.h warnings it's repeating on each file.

1>------ Build started: Project: cairo, Configuration: Debug Win32 ------
1>  cairo.c
1>d:\dila\litepdf\dependencies\cairo\src\src\cairo-wideint-private.h(177): warning C4146: unary minus operator applied to unsigned type, result still unsigned
1>d:\dila\litepdf\dependencies\cairo\src\src\cairo-wideint-private.h(181): warning C4146: unary minus operator applied to unsigned type, result still unsigned
1>d:\dila\litepdf\dependencies\cairo\src\src\cairo-wideint-private.h(194): warning C4244: 'return' : conversion from 'cairo_int64_t' to 'int32_t', possible loss of data
1>d:\dila\litepdf\dependencies\cairo\src\src\cairo.c(172): error C2425: 'AND' : non-constant expression in 'first operand'
1>d:\dila\litepdf\dependencies\cairo\src\src\cairo.c(172): error C2415: improper operand type
1>d:\dila\litepdf\dependencies\cairo\src\src\cairo.c(172): error C2425: 'SHR' : non-constant expression in 'first operand'
1>d:\dila\litepdf\dependencies\cairo\src\src\cairo.c(172): error C2415: improper operand type
1>d:\dila\litepdf\dependencies\cairo\src\src\cairo.c(172): error C2425: 'SHR' : non-constant expression in 'first operand'
1>d:\dila\litepdf\dependencies\cairo\src\src\cairo.c(172): error C2415: improper operand type
1>d:\dila\litepdf\dependencies\cairo\src\src\cairo.c(172): error C2425: 'SHR' : non-constant expression in 'first operand'
1>d:\dila\litepdf\dependencies\cairo\src\src\cairo.c(172): error C2415: improper operand type
========== Build: 0 succeeded, 1 failed, 4 up-to-date, 0 skipped ==========
Comment 1 Milan Crha 2011-03-08 22:43:42 UTC
Oh, I failed to mention, the macro name is CAIRO_ENSURE_UNIQUE
Comment 2 M Joonas Pihlaja 2011-03-09 01:06:02 UTC
Not having access to a windows development platform I can't help you regarding the actual problem with CAIRO_ENSURE_UNIQUE, but the negation warnings in wideint.h are MSVC being overly panicky.  The loss of precision warning however is valid, and in fact looking up the sole user of the function involved points out a bug in either function naming or intention (cairo_fixed_mul_div_floor does not actually floor; it's not essentially functionally different from cairo_fixed_mul_div.)
Comment 3 Andrea Canciani 2011-06-15 07:20:30 UTC
(In reply to comment #0)
> I tried to build cairo 1.10.2 under Microsoft Visual C++ 2010 (10.0) and the
> build fails in cairo.c with the below error. Considering the usage of that
> macro, and that's mostly unused, even in MSVC when compiled for 64bit, then I
> would like to suggest you to remove the macro completely. Thanks in advance.
> 
> Please note also those cairo-wideint-private.h warnings it's repeating on each
> file.
> 
> 1>------ Build started: Project: cairo, Configuration: Debug Win32 ------
> 1>  cairo.c
> 1>d:\dila\litepdf\dependencies\cairo\src\src\cairo-wideint-private.h(177):
> warning C4146: unary minus operator applied to unsigned type, result still
> unsigned
> 1>d:\dila\litepdf\dependencies\cairo\src\src\cairo-wideint-private.h(181):
> warning C4146: unary minus operator applied to unsigned type, result still
> unsigned
> 1>d:\dila\litepdf\dependencies\cairo\src\src\cairo-wideint-private.h(194):
> warning C4244: 'return' : conversion from 'cairo_int64_t' to 'int32_t',
> possible loss of data
> 1>d:\dila\litepdf\dependencies\cairo\src\src\cairo.c(172): error C2425: 'AND' :
> non-constant expression in 'first operand'
> 1>d:\dila\litepdf\dependencies\cairo\src\src\cairo.c(172): error C2415:
> improper operand type
> 1>d:\dila\litepdf\dependencies\cairo\src\src\cairo.c(172): error C2425: 'SHR' :
> non-constant expression in 'first operand'
> 1>d:\dila\litepdf\dependencies\cairo\src\src\cairo.c(172): error C2415:
> improper operand type
> 1>d:\dila\litepdf\dependencies\cairo\src\src\cairo.c(172): error C2425: 'SHR' :
> non-constant expression in 'first operand'
> 1>d:\dila\litepdf\dependencies\cairo\src\src\cairo.c(172): error C2415:
> improper operand type
> 1>d:\dila\litepdf\dependencies\cairo\src\src\cairo.c(172): error C2425: 'SHR' :
> non-constant expression in 'first operand'
> 1>d:\dila\litepdf\dependencies\cairo\src\src\cairo.c(172): error C2415:
> improper operand type
> ========== Build: 0 succeeded, 1 failed, 4 up-to-date, 0 skipped ==========

I recently pushed a changeset that should fix the Makefile.win32-based build.
Can you please check if you can reproduce the problem on cairo/master?
If the problem persists, can you provide some details about the build environment
you are using?

(AFAICT cairo 1.10 should fail to build without even running the compiler if you're
using the command "make -f Makefile.win32 CFG=debug")
Comment 4 Andrea Canciani 2011-07-13 03:10:15 UTC
Please reopen with the steps to reproduce the problem, if it persists.

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.