Bug 88050 - Compiler warning in cairo-gl.h undefined #if check
Summary: Compiler warning in cairo-gl.h undefined #if check
Status: RESOLVED WONTFIX
Alias: None
Product: cairo
Classification: Unclassified
Component: gl backend (show other bugs)
Version: unspecified
Hardware: All FreeBSD
: medium normal
Assignee: cairo-bugs mailing list
QA Contact: cairo-bugs mailing list
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-01-05 12:00 UTC by Koop Mast
Modified: 2015-07-27 21:19 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments
Wrap the CAIRO_HAS_*_FUNCTIONS of the #if checks in a defined() (1.14 KB, text/plain)
2015-01-05 12:00 UTC, Koop Mast
Details

Description Koop Mast 2015-01-05 12:00:27 UTC
Created attachment 111763 [details]
Wrap the CAIRO_HAS_*_FUNCTIONS of the #if checks in a defined()

When building a program that uses the cairo-gl.h from cairo 1.14.0 with clang 3.5. The compiler prints out the following warnings:

/usr/local/include/cairo/cairo-gl.h:95:5: warning: 'CAIRO_HAS_GLX_FUNCTIONS' is not defined, evaluates to 0 [-Wundef]
#if CAIRO_HAS_GLX_FUNCTIONS
    ^
/usr/local/include/cairo/cairo-gl.h:113:5: warning: 'CAIRO_HAS_WGL_FUNCTIONS' is not defined, evaluates to 0 [-Wundef]
#if CAIRO_HAS_WGL_FUNCTIONS
    ^
/usr/local/include/cairo/cairo-gl.h:129:5: warning: 'CAIRO_HAS_EGL_FUNCTIONS' is not defined, evaluates to 0 [-Wundef]
#if CAIRO_HAS_EGL_FUNCTIONS
    ^
Comment 1 Bryce Harrington 2015-06-27 08:16:41 UTC
Potentially any of those could be defined as 0, so we still should check the actual value of the macro in these tests.  But otherwise LGTM.

To ssh://git.cairographics.org/git/cairo
   776dd20..c8b6c60  master -> master

commit c8b6c6066a238cf4cb04679e1149e956b1556a0c
Author: Koop Mast <kwm@rainbow-runner.nl>
Date:   Mon Jan 5 12:49:25 2015 +0100

    cairo-gl: Fix compiler warning if CAIRO_HAS_*_FUNCTIONS is not defined.

    Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=88050

    [Updated to also still check the value of the macros]

    Signed-off-by: Bryce Harrington <bryce@osg.samsung.com>
Comment 2 Chris Wilson 2015-06-27 08:22:10 UTC
This is not a bug, but correct cpp behaviour.

An undefined macro is evaluated as 0.

The preference is to use #if MACRO_NAME rather than #ifdef.
Comment 3 Bryce Harrington 2015-07-27 21:19:57 UTC
Koop, if you installed a cairo with GL enabled, then installed cairo without GL over the top, or else if you were using headers from /usr/local/include/cairo but linking a cairo lib from /usr/lib/, then you might get warnings like those.  But unfortunately those are not issues we can help with in Cairo, you'll just have to fix your system.

Feel free to reopen if you're reproducing those warnings some other way, that we do need to take into consideration.


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.