sahrk / DGGRID

A command-line application that generates and manipulates icosahedral discrete global grids.
GNU Affero General Public License v3.0
78 stars 26 forks source link

Drop M_2PI constant: it causes conflicts with cmath #48

Closed r-barnes closed 1 year ago

r-barnes commented 2 years ago

You're not using this constant anywhere and, due to namespaces, it conflicts with cmath. Removing it seems like the best fix.

sahrk commented 2 years ago

I always include a definition of M_2PI in my constants because for some reason it is isn't defined in math.h. In this case M_2PI is being used in DgProjFuller.cpp and DgProjISEA.cpp. cmath is included in those files, but when I comment out my M_2PI definition it's not getting picked up. Not sure why, but I'm going to table this one for now.

r-barnes commented 2 years ago

@sahrk : My bad, it turns out M_2PI is coming in from somewhere in Rcpp. Changing the variable name to dgM_2PI or using namespaces would both fix the issue.

I've updated the diff to use #ifdef DGGRIDR to suppress the issue by having dggridR use Rcpp's value for M_2PI. But this isn't the best solution since it means the value they use and the value you use could be different, compromising reproducibility.