mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-06-04 22:17:01 +08:00
[NPS] Fixed NPS warnings on OS X
OS X uses clang to compile the code, thus we have a bit different warning system. Now the C++ code is being compiled with the G++ clang compiler instead of GCC. Actually compile C++ files with CXX and C files with CC. Also fixed some other warnings including UTF-16 character usage. Converted config report warningt to PRINT_CONFIG_MSG. We need to push the diagnostics first for clang. Added GNU99 standard flag to the C targets.
This commit is contained in:
+26
-12
@@ -26,7 +26,6 @@
|
||||
|
||||
SRC_ARCH = arch/sim
|
||||
|
||||
CC = g++
|
||||
OPT ?= 2
|
||||
SIMDIR = $(PAPARAZZI_SRC)/sw/simulator
|
||||
|
||||
@@ -39,6 +38,14 @@ CFLAGS += $($(TARGET).CFLAGS)
|
||||
CFLAGS += $(LOCAL_CFLAGS)
|
||||
CFLAGS += -O$(OPT)
|
||||
CFLAGS += -g
|
||||
CFLAGS += -std=gnu99
|
||||
|
||||
CXXFLAGS = -W -Wall
|
||||
CXXFLAGS += $(INCLUDES)
|
||||
CXXFLAGS += $($(TARGET).CFLAGS)
|
||||
CXXFLAGS += $(LOCAL_CFLAGS)
|
||||
CXXFLAGS += -O$(OPT)
|
||||
CXXFLAGS += -g
|
||||
|
||||
LDFLAGS += $($(TARGET).LDFLAGS)
|
||||
|
||||
@@ -48,7 +55,8 @@ LDFLAGS += $($(TARGET).LDFLAGS)
|
||||
|
||||
$(TARGET).srcsnd = $(notdir $($(TARGET).srcs))
|
||||
$(TARGET).objso = $($(TARGET).srcs:%.c=$(OBJDIR)/%.o)
|
||||
$(TARGET).objs = $($(TARGET).objso:%.S=$(OBJDIR)/%.o)
|
||||
$(TARGET).objsoxx = $($(TARGET).objso:%.cpp=$(OBJDIR)/%.o)
|
||||
$(TARGET).objs = $($(TARGET).objsoxx:%.S=$(OBJDIR)/%.o)
|
||||
|
||||
all compile: check_jsbsim $(OBJDIR)/simsitl
|
||||
|
||||
@@ -59,7 +67,7 @@ check_jsbsim:
|
||||
|
||||
$(OBJDIR)/simsitl : $($(TARGET).objs)
|
||||
@echo LD $@
|
||||
$(Q)$(CC) $(CFLAGS) -o $@ $($(TARGET).objs) $(LDFLAGS)
|
||||
$(Q)$(CXX) $(CXXFLAGS) -o $@ $($(TARGET).objs) $(LDFLAGS)
|
||||
|
||||
|
||||
%.s: %.c
|
||||
@@ -74,9 +82,9 @@ $(OBJDIR)/%.s: %.c
|
||||
$(CC) $(CFLAGS) -S -o $@ $<
|
||||
|
||||
$(OBJDIR)/%.s: %.cpp
|
||||
@echo CC $@
|
||||
@echo CXX $@
|
||||
$(Q)test -d $(dir $@) || mkdir -p $(dir $@)
|
||||
$(CC) $(CFLAGS) -S -o $@ $<
|
||||
$(CXX) $(CXXFLAGS) -S -o $@ $<
|
||||
|
||||
$(OBJDIR)/%.o: %.c $(OBJDIR)/../Makefile.ac
|
||||
@echo CC $@
|
||||
@@ -84,20 +92,26 @@ $(OBJDIR)/%.o: %.c $(OBJDIR)/../Makefile.ac
|
||||
$(Q)$(CC) $(CFLAGS) -c -o $@ $<
|
||||
|
||||
$(OBJDIR)/%.o: %.cpp $(OBJDIR)/../Makefile.ac
|
||||
@echo CC $@
|
||||
@echo CXX $@
|
||||
$(Q)test -d $(dir $@) || mkdir -p $(dir $@)
|
||||
$(Q)$(CC) $(CFLAGS) -c -o $@ $<
|
||||
$(Q)$(CXX) $(CXXFLAGS) -c -o $@ $<
|
||||
|
||||
.PHONY: all compile check_jsbsim
|
||||
|
||||
#
|
||||
# Dependencies
|
||||
#
|
||||
$(OBJDIR)/.depend:
|
||||
@test -d $(OBJDIR) || mkdir -p $(OBJDIR)
|
||||
@echo DEPEND $@
|
||||
$(Q)$(CC) -MM -MG $(CFLAGS) $($(TARGET).srcs) | sed 's|\([^\.]*\.o\)|$(OBJDIR)/\1|' > $@
|
||||
|
||||
$(OBJDIR)/%.d: %.c
|
||||
@echo DEP $@
|
||||
$(Q)test -d $(dir $@) || mkdir -p $(dir $@)
|
||||
$(Q)$(CC) -MM -MG $(CFLAGS) $< | sed 's|\([^\.]*\.o\)|$(OBJDIR)/\1|' > $(OBJDIR)/$*.d
|
||||
|
||||
$(OBJDIR)/%.d: %.cpp $(OBJDIR)/../Makefile.ac
|
||||
@echo DEP $@
|
||||
$(Q)test -d $(dir $@) || mkdir -p $(dir $@)
|
||||
$(Q)$(CXX) -MM -MG $(CXXFLAGS) $< | sed 's|\([^\.]*\.o\)|$(OBJDIR)/\1|' > $(OBJDIR)/$*.d
|
||||
|
||||
ifneq ($(MAKECMDGOALS),clean)
|
||||
-include $(OBJDIR)/.depend
|
||||
-include $($(TARGET).objs:.o=.d)
|
||||
endif
|
||||
|
||||
@@ -39,7 +39,7 @@ endif
|
||||
|
||||
|
||||
nps.srcs += $(NPSDIR)/nps_main.c \
|
||||
$(NPSDIR)/nps_fdm_jsbsim.c \
|
||||
$(NPSDIR)/nps_fdm_jsbsim.cpp \
|
||||
$(NPSDIR)/nps_random.c \
|
||||
$(NPSDIR)/nps_sensors.c \
|
||||
$(NPSDIR)/nps_sensors_utils.c \
|
||||
|
||||
@@ -28,14 +28,10 @@
|
||||
|
||||
#include "subsystems/settings.h"
|
||||
|
||||
int32_t persistent_write(uint32_t ptr, uint32_t size) {
|
||||
ptr=ptr;
|
||||
size=size;
|
||||
int32_t persistent_write(uint32_t ptr UNUSED, uint32_t size UNUSED) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
int32_t persistent_read(uint32_t ptr, uint32_t size) {
|
||||
ptr=ptr;
|
||||
size=size;
|
||||
int32_t persistent_read(uint32_t ptr UNUSED, uint32_t size UNUSED) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ struct EnuCoor_i navigation_carrot;
|
||||
|
||||
struct EnuCoor_i nav_last_point;
|
||||
|
||||
uint8_t last_wp __attribute__ ((unused));
|
||||
uint8_t last_wp UNUSED;
|
||||
|
||||
/** Maximum distance from HOME waypoint before going into failsafe mode */
|
||||
#ifndef FAILSAFE_MODE_DISTANCE
|
||||
@@ -180,7 +180,7 @@ void nav_init(void) {
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline void nav_advance_carrot(void) {
|
||||
static inline void UNUSED nav_advance_carrot(void) {
|
||||
struct EnuCoor_i *pos = stateGetPositionEnu_i();
|
||||
/* compute a vector to the waypoint */
|
||||
struct Int32Vect2 path_to_waypoint;
|
||||
|
||||
@@ -136,7 +136,7 @@ extern void nav_circle(struct EnuCoor_i * wp_center, int32_t radius);
|
||||
}
|
||||
|
||||
#define NavCircleCount() (abs(nav_circle_radians) / INT32_ANGLE_2_PI)
|
||||
#define NavCircleQdr() ({ int32_t qdr = INT32_DEG_OF_RAD(INT32_ANGLE_2_PI_2 - nav_circle_qdr) >> INT32_ANGLE_FRAC; NormCourse(qdr); qdr; })
|
||||
#define NavCircleQdr() ({ int32_t qdr = INT32_DEG_OF_RAD(INT32_ANGLE_2_PI_2 - nav_circle_qdr) >> INT32_ANGLE_FRAC; NormCourse(qdr); qdr; })
|
||||
|
||||
/** True if x (in degrees) is close to the current QDR (less than 10 degrees)*/
|
||||
#define NavQdrCloseTo(x) {}
|
||||
|
||||
@@ -140,7 +140,7 @@ double gc_of_gd_lat_d(double gd_lat, double hmsl) {
|
||||
|
||||
#include "math/pprz_geodetic_utm.h"
|
||||
|
||||
static inline double isometric_latitude_d(double phi, double e) {
|
||||
static inline double UNUSED isometric_latitude_d(double phi, double e) {
|
||||
return log (tan (M_PI_4 + phi / 2.0)) - e / 2.0 * log((1.0 + e * sin(phi)) / (1.0 - e * sin(phi)));
|
||||
}
|
||||
|
||||
|
||||
@@ -30,6 +30,10 @@
|
||||
#ifndef PPRZ_GEODETIC_DOUBLE_H
|
||||
#define PPRZ_GEODETIC_DOUBLE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "pprz_geodetic.h"
|
||||
#include "pprz_algebra_double.h"
|
||||
#include "std.h"
|
||||
@@ -114,5 +118,8 @@ extern void ecef_of_ned_vect_d(struct EcefCoor_d* ecef, struct LtpDef_d* def, st
|
||||
|
||||
extern double gc_of_gd_lat_d(double gd_lat, double hmsl);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* PPRZ_GEODETIC_DOUBLE_H */
|
||||
|
||||
@@ -142,7 +142,7 @@ float ins_pitch_neutral = INS_PITCH_NEUTRAL_DEFAULT;
|
||||
struct AhrsIntCmplQuat ahrs_impl;
|
||||
|
||||
static inline void set_body_state_from_quat(void);
|
||||
static inline void ahrs_update_mag_full(void);
|
||||
static inline void UNUSED ahrs_update_mag_full(void);
|
||||
static inline void ahrs_update_mag_2d(void);
|
||||
|
||||
#if PERIODIC_TELEMETRY
|
||||
|
||||
@@ -226,4 +226,10 @@ static inline bool_t str_equal(const char * a, const char * b) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#ifdef __GNUC__
|
||||
# define UNUSED __attribute__((__unused__))
|
||||
#else
|
||||
# define UNUSED
|
||||
#endif
|
||||
|
||||
#endif /* STD_H */
|
||||
|
||||
@@ -22,6 +22,9 @@
|
||||
#ifndef NPS_FDM
|
||||
#define NPS_FDM
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "std.h"
|
||||
#include "math/pprz_geodetic_double.h"
|
||||
@@ -96,4 +99,8 @@ extern void nps_fdm_init(double dt);
|
||||
extern void nps_fdm_run_step(bool_t launch, double* commands, int commands_nb);
|
||||
extern void nps_fdm_set_wind(double speed, double dir, int turbulence_severity);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* NPS_FDM */
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#include <stdio.h>
|
||||
|
||||
// ignore stupid warnings in JSBSim
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wunused-parameter"
|
||||
#include <FGFDMExec.h>
|
||||
#pragma GCC diagnostic pop
|
||||
@@ -475,17 +476,17 @@ static void init_ltp(void) {
|
||||
|
||||
|
||||
#if !NPS_CALC_GEO_MAG && defined(AHRS_H_X)
|
||||
#pragma message "Using magnetic field as defined in airframe file (AHRS section)."
|
||||
PRINT_CONFIG_MSG("Using magnetic field as defined in airframe file (AHRS section).")
|
||||
fdm.ltp_h.x = AHRS_H_X;
|
||||
fdm.ltp_h.y = AHRS_H_Y;
|
||||
fdm.ltp_h.z = AHRS_H_Z;
|
||||
#elif !NPS_CALC_GEO_MAG && defined(INS_H_X)
|
||||
#pragma message "Using magnetic field as defined in airframe file (INS section)."
|
||||
PRINT_CONFIG_MSG("Using magnetic field as defined in airframe file (INS section).")
|
||||
fdm.ltp_h.x = INS_H_X;
|
||||
fdm.ltp_h.y = INS_H_Y;
|
||||
fdm.ltp_h.z = INS_H_Z;
|
||||
#else
|
||||
#pragma message "Using WMM2010 model to calculate magnetic field at simulated location."
|
||||
PRINT_CONFIG_MSG("Using WMM2010 model to calculate magnetic field at simulated location.")
|
||||
/* calculation of magnetic field according to WMM2010 model */
|
||||
double gha[MAXCOEFF];
|
||||
|
||||
@@ -114,7 +114,7 @@
|
||||
#define JS_NB_BUTTONS 0
|
||||
#endif
|
||||
|
||||
NpsJoystick nps_joystick;
|
||||
struct NpsJoystick nps_joystick;
|
||||
SDL_Joystick *sdl_joystick;
|
||||
SDL_Event sdl_event;
|
||||
|
||||
|
||||
@@ -31,8 +31,6 @@ static unsigned long int randlcg(void);
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
void double_vect3_add_gaussian_noise(struct DoubleVect3* vect, struct DoubleVect3* std_dev) {
|
||||
vect->x += get_gaussian_noise() * std_dev->x;
|
||||
vect->y += get_gaussian_noise() * std_dev->y;
|
||||
|
||||
@@ -79,7 +79,7 @@ void nps_sensor_gps_run_step(struct NpsSensorGps* gps, double time) {
|
||||
*/
|
||||
/* convert current ecef reading to lla */
|
||||
struct LlaCoor_d cur_lla_reading;
|
||||
lla_of_ecef_d(&cur_lla_reading, (EcefCoor_d*) &cur_pos_reading);
|
||||
lla_of_ecef_d(&cur_lla_reading, (struct EcefCoor_d*) &cur_pos_reading);
|
||||
|
||||
/* store that for later and retrieve a previously stored data */
|
||||
UpdateSensorLatency(time, &cur_lla_reading, &gps->lla_history, gps->pos_latency, &gps->lla_pos);
|
||||
|
||||
Reference in New Issue
Block a user