[Bug 24318] New: Fix building of GLSL demos which use M_PI when M_PI is not defined by math.h

View: New views
12 Messages — Rating Filter:   Alert me  

[Bug 24318] New: Fix building of GLSL demos which use M_PI when M_PI is not defined by math.h

by Bugzilla from bugzilla-daemon@freedesktop.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

http://bugs.freedesktop.org/show_bug.cgi?id=24318

           Summary: Fix building of GLSL demos which use M_PI when M_PI is
                    not defined by math.h
           Product: Mesa
           Version: git
          Platform: x86 (IA32)
        OS/Version: Cygwin
            Status: NEW
          Severity: minor
          Priority: medium
         Component: Demos
        AssignedTo: mesa3d-dev@...
        ReportedBy: jon.turney@...


Created an attachment (id=30074)
 --> (http://bugs.freedesktop.org/attachment.cgi?id=30074)
Patch to fix building of GLSL demos which use M_PI when M_PI is not defined by
math.h

Some <math.h> files do not define M_PI, in which case, we must provide our own
definition.  This is done for most demos, but not for the GLSL demos.


--
Configure bugmail: http://bugs.freedesktop.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
Mesa3d-dev mailing list
Mesa3d-dev@...
https://lists.sourceforge.net/lists/listinfo/mesa3d-dev

[Bug 24318] Fix building of GLSL demos which use M_PI when M_PI is not defined by math.h

by Bugzilla from bugzilla-daemon@freedesktop.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

http://bugs.freedesktop.org/show_bug.cgi?id=24318


Brian Paul <brian.e.paul@...> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED




--- Comment #1 from Brian Paul <brian.e.paul@...>  2009-10-05 10:09:25 PST ---
Committed to the 7.6 branch. Thanks.


--
Configure bugmail: http://bugs.freedesktop.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
Mesa3d-dev mailing list
Mesa3d-dev@...
https://lists.sourceforge.net/lists/listinfo/mesa3d-dev

[Bug 24318] Fix building of GLSL demos which use M_PI when M_PI is not defined by math.h

by Bugzilla from bugzilla-daemon@freedesktop.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

http://bugs.freedesktop.org/show_bug.cgi?id=24318





--- Comment #2 from Ian Romanick <idr@...>  2009-10-05 10:18:33 PST ---
NAK!!!  The only systems where I have seen M_PI not defined is MSVC.  On MSVC
it is not defined /by default/, but it can be enabled by defining
_USE_MATH_DEFINES.  It would be much better to define _USE_MATH_DEFINES from
the build system than pollute the code with this cruft.


--
Configure bugmail: http://bugs.freedesktop.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
Mesa3d-dev mailing list
Mesa3d-dev@...
https://lists.sourceforge.net/lists/listinfo/mesa3d-dev

[Bug 24318] Fix building of GLSL demos which use M_PI when M_PI is not defined by math.h

by Bugzilla from bugzilla-daemon@freedesktop.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

http://bugs.freedesktop.org/show_bug.cgi?id=24318





--- Comment #3 from Jon TURNEY <jon.turney@...>  2009-10-05 10:34:51 PST ---
(In reply to comment #2)
> NAK!!!  The only systems where I have seen M_PI not defined is MSVC.  On MSVC
> it is not defined /by default/, but it can be enabled by defining
> _USE_MATH_DEFINES.  It would be much better to define _USE_MATH_DEFINES from
> the build system than pollute the code with this cruft.

I'm building with gcc under Cygwin.   Your point is well made, but...

$ grep -r "#define M_PI" * | wc -l
48


--
Configure bugmail: http://bugs.freedesktop.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
Mesa3d-dev mailing list
Mesa3d-dev@...
https://lists.sourceforge.net/lists/listinfo/mesa3d-dev

[Bug 24318] Fix building of GLSL demos which use M_PI when M_PI is not defined by math.h

by Bugzilla from bugzilla-daemon@freedesktop.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

http://bugs.freedesktop.org/show_bug.cgi?id=24318





--- Comment #4 from Brian Paul <brian.e.paul@...>  2009-10-05 10:38:27 PST ---
Just a historical note: I recall needing the #ifndef M_PI stuff many years ago
on some Unix variants (HP-UX?), before Mesa was running on Windows.

If you want to revert the patch and fix the compile flags, that's OK w/ me.  As
Jon points out, a lot of other demos do this too.


--
Configure bugmail: http://bugs.freedesktop.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
Mesa3d-dev mailing list
Mesa3d-dev@...
https://lists.sourceforge.net/lists/listinfo/mesa3d-dev

[Bug 24318] Fix building of GLSL demos which use M_PI when M_PI is not defined by math.h

by Bugzilla from bugzilla-daemon@freedesktop.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

http://bugs.freedesktop.org/show_bug.cgi?id=24318





--- Comment #5 from Jon TURNEY <jon.turney@...>  2009-10-05 11:02:33 PST ---
I'll see if I can cook up a patch to do this 'properly' (or at least 'better')

For the compiler/header combination I have, -std=c99 -U__STRICT_ANSI__ seems to
be needed to let math.h defined M_PI


--
Configure bugmail: http://bugs.freedesktop.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
Mesa3d-dev mailing list
Mesa3d-dev@...
https://lists.sourceforge.net/lists/listinfo/mesa3d-dev

[Bug 24318] Fix building of GLSL demos which use M_PI when M_PI is not defined by math.h

by Bugzilla from bugzilla-daemon@freedesktop.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

http://bugs.freedesktop.org/show_bug.cgi?id=24318





--- Comment #6 from Tom Fogal <tfogal@...>  2009-10-05 11:12:15 PST ---
bugzilla-daemon@... writes:
> http://bugs.freedesktop.org/show_bug.cgi?id=24318
>
> --- Comment #2 from Ian Romanick <idr@...>  2009-10-05
>
> NAK!!!  The only systems where I have seen M_PI not defined is
> MSVC.  On MSVC it is not defined /by default/, but it can be enabled
> by defining _USE_MATH_DEFINES.  It would be much better to define
> _USE_MATH_DEFINES from the build system than pollute the code with
> this cruft.

Not that using _USE_MATH_DEFINES sounds like a bad idea, but I don't
see M_PI mentioned in the n1336 draft.  I'm not sure where I got n1336,
but probably somewhere here:

  http://www.open-std.org/jtc1/sc22/wg14/

Thus, I would argue that *both* this and the build system define should
be used.

-tom


--
Configure bugmail: http://bugs.freedesktop.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
Mesa3d-dev mailing list
Mesa3d-dev@...
https://lists.sourceforge.net/lists/listinfo/mesa3d-dev

[Bug 24318] Fix building of GLSL demos which use M_PI when M_PI is not defined by math.h

by Bugzilla from bugzilla-daemon@freedesktop.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

http://bugs.freedesktop.org/show_bug.cgi?id=24318


Jon TURNEY <jon.turney@...> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|FIXED                       |




--- Comment #7 from Jon TURNEY <jon.turney@...>  2009-10-07 04:31:13 PST ---
Reopening so I don't forget about this


--
Configure bugmail: http://bugs.freedesktop.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Mesa3d-dev mailing list
Mesa3d-dev@...
https://lists.sourceforge.net/lists/listinfo/mesa3d-dev

[Bug 24318] Fix building of GLSL demos which use M_PI when M_PI is not defined by math.h

by Bugzilla from bugzilla-daemon@freedesktop.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

http://bugs.freedesktop.org/show_bug.cgi?id=24318





--- Comment #8 from Matt Turner <mattst88@...>  2009-10-07 06:37:45 PST ---
IIRC when compiling with gcc -ansi, M_PI isn't defined.

In my math.h, its definition is wrapped in '#if defined __USE_BSD || defined
__USE_XOPEN'


--
Configure bugmail: http://bugs.freedesktop.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Mesa3d-dev mailing list
Mesa3d-dev@...
https://lists.sourceforge.net/lists/listinfo/mesa3d-dev

[Bug 24318] Fix building of GLSL demos which use M_PI when M_PI is not defined by math.h

by Bugzilla from bugzilla-daemon@freedesktop.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

http://bugs.freedesktop.org/show_bug.cgi?id=24318





--- Comment #9 from Jon TURNEY <jon.turney@...>  2009-10-24 10:17:59 PST ---
Created an attachment (id=30659)
 --> (http://bugs.freedesktop.org/attachment.cgi?id=30659)
Remove the various definitions of M_PI, except in compiler.h


--
Configure bugmail: http://bugs.freedesktop.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Mesa3d-dev mailing list
Mesa3d-dev@...
https://lists.sourceforge.net/lists/listinfo/mesa3d-dev

[Bug 24318] Fix building of GLSL demos which use M_PI when M_PI is not defined by math.h

by Bugzilla from bugzilla-daemon@freedesktop.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

http://bugs.freedesktop.org/show_bug.cgi?id=24318


Jon TURNEY <jon.turney@...> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #30074|0                           |1
        is obsolete|                            |




--- Comment #10 from Jon TURNEY <jon.turney@...>  2009-10-24 10:18:46 PST ---
Created an attachment (id=30660)
 --> (http://bugs.freedesktop.org/attachment.cgi?id=30660)
Add an autoconf check that math.h defines M_PI


--
Configure bugmail: http://bugs.freedesktop.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Mesa3d-dev mailing list
Mesa3d-dev@...
https://lists.sourceforge.net/lists/listinfo/mesa3d-dev

[Bug 24318] Fix building of GLSL demos which use M_PI when M_PI is not defined by math.h

by Bugzilla from bugzilla-daemon@freedesktop.org :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

http://bugs.freedesktop.org/show_bug.cgi?id=24318





--- Comment #11 from Jon TURNEY <jon.turney@...>  2009-10-24 10:24:29 PST ---
Attached a couple of patches with an effort to do this better.

As written, this falls back to explicitly defining M_PI using -D o the compiler
command line if it can't make math.h define it.  This probably isn't a good
idea.  Probably it should do nothing, but this probably breaks stuff on some
targets which should include compiler.h but doesn't?

Visual C projects will need updating to use _USE_MATH_DEFINES.

I have assumed that the precision of the value of M_PI is not significant, as
it varies from place to place, which should be the case anyhow, as these values
are only a fall-back

(In reply to comment #8)
> IIRC when compiling with gcc -ansi, M_PI isn't defined.
>
> In my math.h, its definition is wrapped in '#if defined __USE_BSD || defined
> __USE_XOPEN'

I have the same.  I believe that -U__STRICT_ANSI__ is the way to access these
definitions if you want to use -ansi, but this may be incorrect.


--
Configure bugmail: http://bugs.freedesktop.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Mesa3d-dev mailing list
Mesa3d-dev@...
https://lists.sourceforge.net/lists/listinfo/mesa3d-dev