Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dont use _B & _C identifiers #266

Closed
landryb opened this issue Jan 23, 2020 · 1 comment
Closed

dont use _B & _C identifiers #266

landryb opened this issue Jan 23, 2020 · 1 comment

Comments

@landryb
Copy link

landryb commented Jan 23, 2020

(quoting @omoerbeek)

C99 section 7.1.3 reserves all names starting with an underscore followed by an uppercase or another _

while porting gpxsee to OpenBSD (https://marc.info/?l=openbsd-ports-cvs&m=157976764732555&w=2) i got two build failures, because our ctypes.h has this section:

#define _U      0x01
#define _L      0x02
#define _N      0x04
#define _S      0x08
#define _P      0x10
#define _C      0x20
#define _X      0x40
#define _B      0x80

and _C & _B conflicts badly with the vars used in src/map/krovak.h & src/map/albersequal.h

../src/map/krovak.h:21:17: error: expected member name or ';' after declaration specifiers
        double _e, _A, _B, _t0, _n, _r0, _phiP;                                                                                                                                                                  
        ~~~~~~         ^      
/usr/include/ctype.h:52:12: note: expanded from macro '_B'                                                                                                                                                       
#define _B      0x80 

../src/map/albersequal.h:28:9: error: expected member name or ';' after declaration specifiers
        double _C;                              
        ~~~~~~ ^              
/usr/include/ctype.h:50:12: note: expanded from macro '_C'        
#define _C      0x20       

i've patched out those two in our port, replacing _C by C in the header & the corresponding cpp file, but can you use meaningful variables or avoid using _x with uppercase letters ? I can do a PR if you prefer, ofc.

Other than that gpxsee works great on OpenBSD :)

@tumic0
Copy link
Owner

tumic0 commented Jan 23, 2020

Thanks for reporting, I always thought that only two underscores are prohibited...

can you use meaningful variables

The used names are the most meaningful names as those are the characters used in the projection formulas. The most meaningful transcription of Einstein's famous formula would also be something like:

double E = m * sqr(c);
`

@tumic0 tumic0 closed this as completed in d035a30 Jan 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants