jonsowman / cusf-standalone-predictor

Cambridge University Spaceflight landing predictor - a web-based tool for predicting the flight paths of meteorological sounding balloons.
http://habhub.org/predict
GNU General Public License v3.0
70 stars 36 forks source link

Compilation of pred fails on OSX #110

Closed johnboiles closed 10 years ago

johnboiles commented 10 years ago

Possibly a clang vs gcc issue. Compilation fails in pred.c:50 and seem to be related to the gopt_start macro. Here are the errors.

/Users/johnboiles/cusf-standalone-predictor/pred_src/pred.c:50:44: error: expected ';' after struct
    void *options = gopt_sort(&argc, argv, gopt_start(
                                           ^
/Users/johnboiles/cusf-standalone-predictor/pred_src/util/gopt.h:28:106: note: expanded from macro 'gopt_start'
#define gopt_start(...)  (const void*)( const struct { int k; int f; const char *s; const char*const*l; }[]){ __VA_ARGS__, {0}}
                                                                                                         ^
/Users/johnboiles/cusf-standalone-predictor/pred_src/pred.c:50:44: error: expected ')'
/Users/johnboiles/cusf-standalone-predictor/pred_src/util/gopt.h:28:106: note: expanded from macro 'gopt_start'
#define gopt_start(...)  (const void*)( const struct { int k; int f; const char *s; const char*const*l; }[]){ __VA_ARGS__, {0}}
                                                                                                         ^
/Users/johnboiles/cusf-standalone-predictor/pred_src/pred.c:50:44: note: to match this '('
/Users/johnboiles/cusf-standalone-predictor/pred_src/util/gopt.h:28:39: note: expanded from macro 'gopt_start'
#define gopt_start(...)  (const void*)( const struct { int k; int f; const char *s; const char*const*l; }[]){ __VA_ARGS__, {0}}
                                      ^
/Users/johnboiles/cusf-standalone-predictor/pred_src/pred.c:50:44: error: expected expression
    void *options = gopt_sort(&argc, argv, gopt_start(
                                           ^
/Users/johnboiles/cusf-standalone-predictor/pred_src/util/gopt.h:28:106: note: expanded from macro 'gopt_start'
#define gopt_start(...)  (const void*)( const struct { int k; int f; const char *s; const char*const*l; }[]){ __VA_ARGS__, {0}}
                                                                                                         ^
/Users/johnboiles/cusf-standalone-predictor/pred_src/pred.c:50:44: error: expected expression
/Users/johnboiles/cusf-standalone-predictor/pred_src/util/gopt.h:28:106: note: expanded from macro 'gopt_start'
#define gopt_start(...)  (const void*)( const struct { int k; int f; const char *s; const char*const*l; }[]){ __VA_ARGS__, {0}}
adamgreig commented 10 years ago

Hi John,

Odd error. I'm afraid we probably won't be looking to resolve this; the predictor is moving on and this old C codebase is to be deprecated very soon. The latest version is now feature-complete and should hopefully run on OS X, in addition to being a good deal easier to use. See https://github.com/cuspaceflight/tawhiri and http://tawhiri.readthedocs.org/en/latest/.

Since it still needs some 6GB downloaded every 4 hours, we recommend most people use the online version: http://predict.habhub.org/

Hope this helps, and thanks for the bug report!

johnboiles commented 10 years ago

@adamgreig thanks for the quick response. I'll take a look at Tawhiri! Great work on the predictor. Do you happen to know if anyone is using it to provide live prediction based on the current ascent rate / descent rate / and burst altitude of a balloon currently in flight (possibly based on data from aprs.fi or aprs-is)?

Also, here's the quick fix for this issue:

-#define gopt_start(...)  (const void*)( const struct { int k; int f; const char *s; const char*const*l; }[]){ __VA_ARGS__, {0}}
+typedef struct { int k; int f; const char *s; const char*const*l; } kfsl;
+#define gopt_start(...)  (const void*)( const kfsl[]){ __VA_ARGS__, {0}}
adamgreig commented 10 years ago

Yep, it's used on http://spacenear.us to do exactly that, based on data received through habhub/habitat (www.habhub.org and www.github.com/ukhas/habitat ). It's also used (though I think through spacenear.us) on http://habhub.org/mt although that's the same data source. Both occasionally import APRS based flights through APRS-IS and aprs.fi.

And wow, thanks for the fix. Not surprised clang got upset with that. What a define. I'll see if we want to merge it into this codebase in case it bites anyone else.

johnboiles commented 10 years ago

Oh awesome, I'll take a look at spacenear.us. Glad someone's already working on it.

Happy to create a pull request if this looks good to you.

adamgreig commented 10 years ago

Sure, a pull request would be great, thanks.