Windows Compilation 0.91pre1
![](https://secure.gravatar.com/avatar/7dcfd3bfbc69fe78d8d995ae357b62c4.jpg?s=120&d=mm&r=g)
I am having some difficulty with the latest code (also for 0.48.5 series) which I didn't have before or didn't notice before. :)
There are lot of places where M_PI and friends is/are used without it/they being in scope. In some files, M_PI is defined right in with #ifndef block. What would be the fastest way (other than modifying the source all over the place) of rectifying this?
A lot of the Windows specific stuff is defined with the #ifdef WIN32 block.
However, in my case it only works if it's _WIN32 and not WIN32. This of course I can pass on the command line to gcc. Would be nice if it was standard as say glib or gimp.
Thanks, Partha
![](https://secure.gravatar.com/avatar/7dcfd3bfbc69fe78d8d995ae357b62c4.jpg?s=120&d=mm&r=g)
No response? I was going by the standards and using -std=c++11.
Shouldn't the code be standardized?
Thanks, Partha
On Sat, Jun 21, 2014 at 2:16 PM, Partha Bagchi <partha1b@...400...> wrote:
I am having some difficulty with the latest code (also for 0.48.5 series) which I didn't have before or didn't notice before. :)
There are lot of places where M_PI and friends is/are used without it/they being in scope. In some files, M_PI is defined right in with #ifndef block. What would be the fastest way (other than modifying the source all over the place) of rectifying this?
A lot of the Windows specific stuff is defined with the #ifdef WIN32 block.
However, in my case it only works if it's _WIN32 and not WIN32. This of course I can pass on the command line to gcc. Would be nice if it was standard as say glib or gimp.
Thanks, Partha
![](https://secure.gravatar.com/avatar/63453c8b45c819c09599328f046818cf.jpg?s=120&d=mm&r=g)
On 22-6-2014 6:54, Partha Bagchi wrote:
No response? I was going by the standards and using -std=c++11.
Well... 11 hours to respond to an email is not a whole lot. Patience!
Shouldn't the code be standardized?
There is no standardized way of determining what OS you are compiling for. However, _WIN32 seems more common than WIN32. See, e.g. here: http://sourceforge.net/p/predef/wiki/OperatingSystems/
So, we should be able to change all WIN32 to _WIN32 and improve compatibility. The standard Windows build system (btool/build.xml) explicitly defines WIN32 in config.h.
About M_PI, <2geom/angle.h> defines it if it is not already defined. If there are many other constants needed (Liam mentioned sqrt(2)), we could add <geom/constants.h> file to collect all those. Regardless, I think you cannot escape modifying the source code, or temporarily adding the missing defines to the gcc cmdline.
regards, Johan
Thanks, Partha
On Sat, Jun 21, 2014 at 2:16 PM, Partha Bagchi <partha1b@...400... mailto:partha1b@...400...> wrote:
I am having some difficulty with the latest code (also for 0.48.5 series) which I didn't have before or didn't notice before. :) There are lot of places where M_PI and friends is/are used without it/they being in scope. In some files, M_PI is defined right in with #ifndef block. What would be the fastest way (other than modifying the source all over the place) of rectifying this? A lot of the Windows specific stuff is defined with the #ifdef WIN32 block. However, in my case it only works if it's _WIN32 and not WIN32. This of course I can pass on the command line to gcc. Would be nice if it was standard as say glib or gimp. Thanks, Partha
![](https://secure.gravatar.com/avatar/05c543fd064cf80de43fcaaf05a528c8.jpg?s=120&d=mm&r=g)
There is no standardized way of determining what OS you are compiling for. However, _WIN32 seems more common than WIN32. See, e.g. here: http://sourceforge.net/p/predef/wiki/OperatingSystems/ So, we should be able to change all WIN32 to _WIN32 and improve compatibility. The standard Windows build system (btool/build.xml) explicitly defines WIN32 in config.h.
That's correct. Also note that Microsoft's compiler does *not *define __WIN32__, so we should stop checking for that as well.
About M_PI, <2geom/angle.h> defines it if it is not already defined. If
there are many other constants needed (Liam mentioned sqrt(2)), we could add <geom/constants.h> file to collect all those. Regardless, I think you cannot escape modifying the source code, or temporarily adding the missing defines to the gcc cmdline.
Looks like we need, at a bare minimum: M_PI M_PI_2 M_SQRT2 (this is the default zoom factor in Inkscape)
Although defining others http://msdn.microsoft.com/en-us/library/4hwaceh6.aspx would be great, too.
![](https://secure.gravatar.com/avatar/7dcfd3bfbc69fe78d8d995ae357b62c4.jpg?s=120&d=mm&r=g)
On Sun, Jun 22, 2014 at 10:22 AM, Liam White <inkscapebrony@...400...> wrote:
There is no standardized way of determining what OS you are compiling for.
However, _WIN32 seems more common than WIN32. See, e.g. here: http://sourceforge.net/p/predef/wiki/OperatingSystems/ So, we should be able to change all WIN32 to _WIN32 and improve compatibility. The standard Windows build system (btool/build.xml) explicitly defines WIN32 in config.h.
That's correct. Also note that Microsoft's compiler does *not *define __WIN32__, so we should stop checking for that as well.
About M_PI, <2geom/angle.h> defines it if it is not already defined. If
there are many other constants needed (Liam mentioned sqrt(2)), we could add <geom/constants.h> file to collect all those. Regardless, I think you cannot escape modifying the source code, or temporarily adding the missing defines to the gcc cmdline.
Looks like we need, at a bare minimum: M_PI M_PI_2 M_SQRT2 (this is the default zoom factor in Inkscape)
Although defining others http://msdn.microsoft.com/en-us/library/4hwaceh6.aspx would be great, too.
These are actually defined and if you don't compile with C++11 then you can get away with it.
My suggestion would be either
#define _USE_MATH_DEFINES #include <cmath>
right at the top or
or
const double pi = boost::math::constants::pi<double>();
Moreover, simply collecting them in geom/constants.h may not cover all since M_PI is used in other places as well such as widgets and tools?
Thanks, Partha
![](https://secure.gravatar.com/avatar/63453c8b45c819c09599328f046818cf.jpg?s=120&d=mm&r=g)
On 22-6-2014 20:22, Partha Bagchi wrote:
On Sun, Jun 22, 2014 at 10:22 AM, Liam White <inkscapebrony@...400... mailto:inkscapebrony@...400...> wrote:
There is no standardized way of determining what OS you are compiling for. However, _WIN32 seems more common than WIN32. See, e.g. here: http://sourceforge.net/p/predef/wiki/OperatingSystems/ So, we should be able to change all WIN32 to _WIN32 and improve compatibility. The standard Windows build system (btool/build.xml) explicitly defines WIN32 in config.h. That's correct. Also note that Microsoft's compiler does /not /define __WIN32__, so we should stop checking for that as well. About M_PI, <2geom/angle.h> defines it if it is not already defined. If there are many other constants needed (Liam mentioned sqrt(2)), we could add <geom/constants.h> file to collect all those. Regardless, I think you cannot escape modifying the source code, or temporarily adding the missing defines to the gcc cmdline. Looks like we need, at a bare minimum: M_PI M_PI_2 M_SQRT2 (this is the default zoom factor in Inkscape) Although defining others <http://msdn.microsoft.com/en-us/library/4hwaceh6.aspx> would be great, too.
These are actually defined and if you don't compile with C++11 then you can get away with it.
My suggestion would be either
#define _USE_MATH_DEFINES #include <cmath>
right at the top or
or |const double pi= boost::math::constants::pi<double>();| Moreover, simply collecting them in geom/constants.h may not cover all since M_PI is used in other places as well such as widgets and tools?
Yes, so these files should include geom/constants.h. The point is to localize the code that does this non-standard stuff, so it is easily changed later on if needs be.
regards, Johan
![](https://secure.gravatar.com/avatar/63453c8b45c819c09599328f046818cf.jpg?s=120&d=mm&r=g)
On 22-6-2014 21:02, Johan Engelen wrote:
On 22-6-2014 20:22, Partha Bagchi wrote:
On Sun, Jun 22, 2014 at 10:22 AM, Liam White <inkscapebrony@...400... mailto:inkscapebrony@...400...> wrote:
There is no standardized way of determining what OS you are compiling for. However, _WIN32 seems more common than WIN32. See, e.g. here: http://sourceforge.net/p/predef/wiki/OperatingSystems/ So, we should be able to change all WIN32 to _WIN32 and improve compatibility. The standard Windows build system (btool/build.xml) explicitly defines WIN32 in config.h. That's correct. Also note that Microsoft's compiler does /not /define __WIN32__, so we should stop checking for that as well. About M_PI, <2geom/angle.h> defines it if it is not already defined. If there are many other constants needed (Liam mentioned sqrt(2)), we could add <geom/constants.h> file to collect all those. Regardless, I think you cannot escape modifying the source code, or temporarily adding the missing defines to the gcc cmdline. Looks like we need, at a bare minimum: M_PI M_PI_2 M_SQRT2 (this is the default zoom factor in Inkscape) Although defining others <http://msdn.microsoft.com/en-us/library/4hwaceh6.aspx> would be great, too.
These are actually defined and if you don't compile with C++11 then you can get away with it.
My suggestion would be either
#define _USE_MATH_DEFINES #include <cmath>
right at the top or
or |const double pi= boost::math::constants::pi<double>();| Moreover, simply collecting them in geom/constants.h may not cover all since M_PI is used in other places as well such as widgets and tools?
Yes, so these files should include geom/constants.h. The point is to localize the code that does this non-standard stuff, so it is easily changed later on if needs be.
boost's constants header seems to be a good / better alternative. Go for that if you want :-)
cheers, Johan
participants (3)
-
Johan Engelen
-
Liam White
-
Partha Bagchi