TEOS-10 / GSW-C

C implementation of the Thermodynamic Equation Of Seawater - 2010 (TEOS-10)
Other
18 stars 17 forks source link

[ERROR] GSW and Arduino: Warning: floating constant exceeds range of 'double' [-Woverflow] #22

Closed shCampos closed 6 years ago

shCampos commented 6 years ago

Hello.

I applied the library in Arduino, more specifically the function "gsw_ps_from_c.c". However, when I compiled it it gave the following error: C:\Program Files (x86)\Arduino\libraries\GSW-C-master/gsw_check_data.c:10148:1: warning: floating constant exceeds range of 'double' [-Woverflow]

Can anybody help me?

efiring commented 6 years ago

I think you have a corrupted file. That line (10148) in gsw_check_data.c is the same as many lines before and after it, and has nothing in it that would trigger such a warning. How did you download your files? Did you clone the git repo? If so, use 'git status' and 'git diff' to see if your working directory is clean.

shCampos commented 6 years ago

@efiring I downloaded the library in a zip file and unpacked it in the Arduino libraries folder. I have refactored the same process now and gave the following error:

`C:\Program Files (x86)\Arduino\libraries\GSW-C-master/gswteos-10.h:18:21: fatal error: complex.h: No such file or directory

include

                 ^

compilation terminated.`

From the little I understand, is a standard C library missing. Do I just install the .h file or the whole package?

efiring commented 6 years ago

A little Googling suggests that Arduino is actually providing a C++ compiler, not a C compiler. One of the big differences is in the way complex numbers are handled. The situation here is similar to that with Microsoft C: the C compatibility does not include the modern C (C99) facility for handling complex numbers. I ran into that with GSW-Python, and my solution was to make a C++ variant of the library which is used when the Python library is built on Windows.

If you don't need the whole library but just the one function, then you might do better to extract that function into your own very small bit of code instead of trying to build and install the library. The function itself is quite simple and does not require complex numbers. It's even simpler if you don't need the adjustment for SP<2.

shCampos commented 6 years ago

@efiring , I thought of copying only the function, but I was confused when I saw that the function loads the constants, as noted below:

double gsw_sp_from_c(double c, double t, double p){ GSW_TEOS10_CONSTANTS; GSW_SP_COEFFICIENTS; ....

And I would need to use the function that adjusts the salinity when it is <2.