A number of changes to build branch 1.0.0 in Windows, using MSVC14...
I thought I had made some of these changes in the win-build3 branch, but they do not seem to have been merged... or maybe merged to master after creating the 1.0.0 branch, or something... but have now done them again...
fg_log.hxxThis can be fixed changing the enum class log_prio to use another name like say ERROR2, as suggested in the win-build3 branch, or something else...
diff --git a/src/fglib/fg_log.hxx b/src/fglib/fg_log.hxx
index 3c650b0..f4362b0 100644
--- a/src/fglib/fg_log.hxx
+++ b/src/fglib/fg_log.hxx
@@ -48,7 +48,7 @@ enum class log_prio
DEBUG, ///< debug messages
URGENT = 64, ///< log always, regardless of logging level
CONSOLE = 128, ///< log to terminal (too)
- ERROR = 192 ///< = URGENT | CONSOLE
+ ERROR2 = 192 ///< = URGENT | CONSOLE
};
/**
And then change each instance of log_prio::ERROR to log_prio::ERROR2, some 31 instances, in fgms.cxx...
getopt functionA previous kludge was to provide such a funtion for a _MSC_VER build in main.cxx but that was a very minimal implmentation...
Could simply move that block out of main.cxx into fgms.cxx where it is used...
Or by adding a FindGetopt.cmake to CMakeLists.txt could find and link to an fuller external library... I have a wingetopt repo, but there is a question of the NetBSD licence being compatible with FG/fgms... but there are other instances if my kludge, only used for a MSVC build is not sufficient...
Feedback welcome...
Had to change this to get it to compile... am sure there is a better change... need to check and search...
diff --git a/src/fglib/fg_geometry.cxx b/src/fglib/fg_geometry.cxx
index e2e668d..ee01ca2 100644
--- a/src/fglib/fg_geometry.cxx
+++ b/src/fglib/fg_geometry.cxx
@@ -363,15 +363,24 @@ namespace
constexpr double SG_NM_TO_METER { 1852.0000 };
constexpr double SG_METER_TO_FEET { 3.28083989501312335958 };
constexpr double SQUASH { 0.9966471893352525192801545 };
-constexpr double E2 { fabs ( 1 - SQUASH * SQUASH ) };
+#ifdef _MSC_VER
+#define E2 fabs ( 1.0 - SQUASH * SQUASH )
+#define E4 ( E2 * E2 )
+#else
+constexpr double E2 { fabs((double)(1.0 - SQUASH * SQUASH)) };
constexpr double E4 { E2 * E2 };
+#endif
constexpr double EQURAD { 6378137.0 };
constexpr double RA2 { 1 / (EQURAD * EQURAD) };
constexpr double SG_180 { 180.0 };
constexpr double SG_PI { 3.1415926535 };
constexpr double SG_RADIANS_TO_DEGREES { SG_180 / SG_PI };
constexpr double SG_DEGREES_TO_RADIANS { SG_PI / SG_180 };
-constexpr float SGMISC_PI { 3.1415926535897932384626433832795029L };
+#ifdef _MSC_VER
+constexpr float SGMISC_PI { (float)3.1415926535897932384626433832795029 };
+#else
+constexpr float SGMISC_PI { 3.1415926535897932384626433832795029L };
+#endif
} // namespace
/**
Ideas very welcome....
arpa/inet.h...Adding #include <winsock2.h> under an #ifdef WIN32 seems to fix this...
But could also include the special config.h generated by cmake, since this also includes winsock2.h...
diff --git a/src/fglib/fg_version.cxx b/src/fglib/fg_version.cxx
index 6b8da71..90c85a1 100644
--- a/src/fglib/fg_version.cxx
+++ b/src/fglib/fg_version.cxx
@@ -20,7 +20,11 @@
// Copyright (C) 2017 Oliver Schroeder
//
+#ifdef WIN32
+#include <WinSock2.h>
+#else
#include <arpa/inet.h>
+#endif
#include "fg_version.hxx"
#include "fg_util.hxx"
With these 4 changes, the source built, but while I was doing this there have been some other changes, ...
Maybe I should hold off on doing this until we have a settled 1.0.0 branch to work on... or part or all the above patches are applied... thanks...
I will look into this, but currently working on libcli
Hi Oliver,
Concerning branch 1.0.0, and a MSVC 14 build...
Thanks for all the changes... mainly everything was
good, but still ran into a few more...
The MS compiler reads all decimal as a
double,unless an 'F' or 'f' is appended... so this
was my first change -
-constexpr float SGMISC_PI { 3.1415926535 };
+constexpr float SGMISC_PI { 3.1415926535f };
Normally this is a 'warning' which can be suppressed,
but with
constexprthis becomes an error...There remains several other warnings of this type,
which I have not fixed at this time, like the
group in
fgms.cxx, the first being -X:\fgms-src\src\fgms\fgms.cxx(2471): warning C4305: '=': truncation from 'double' to 'float'
As indicated this warning 4305 could be suppressed in
CMakeLists.txt, like we already suppress 4146 and 4267,
or removed with either a (float) cast, or adding 'f',
but here only concentrated on errors...
The next problem was the use of 'read' and 'write'
in the re-write of cli_client, so have to add
Next 'getopt' is used in fgms.cxx... thanks for moving
this into msc_getopt.hxx/cxx, so in CMakeLists.txt
added this directory, under
if (MSVC)-I noted in
netsocket.cxxandfg_tracker.cxxyou have added#include <libmsc/msc_unistd.hxx>...These could now be reduced to a simple -
#include "msc_unistd.hxx", but not important...Then added 'msc_getopt.hxx' to the special MSVC
'config.h.msvc' -> 'config.h'...
And at the same time also added -
#include <algorithm> // for std::min, std::max, ...And of course, 'getopt' has to also publically
expose 'optarg' -
That was it... and it built fine... the full diff is
given below -
Have not yet had a chance to
testfgms, but willget to that...
After testing and if you agree with all these I could push them
directly to the
1.0.0branch... if you do not get aroundto adding them, if you get the chance...
What do you think?
Regards,
Geoff.
PS: I am still having troubles with sourceforge at the
moment... tried to post this yesterday, but sf failed!
Hope this clears up soon...