frankheckenbach / ftgl

fork from http://sourceforge.net/projects/ftgl
Other
24 stars 13 forks source link

Strict c89 compliance for header comments and readme update #12

Closed ghost closed 3 years ago

ghost commented 3 years ago

Depending on the compiler (looking at you GCC) using -std=c89 in a project that includes FTGL headers will throw a compilation error because //-style comments aren't a part of the C89 standard.

This pull request simply changes every comment in every header in src/ to the /* */ format, as well as updating the readme version which was neglected when 2.4.0 was released.

frankheckenbach commented 3 years ago

First of all, I don't work with FTGL anymore (see https://github.com/frankheckenbach/ftgl/issues/10), so if you need a patched version, please find another fork or create your own.

Apart from that, I don't really understand the issue. FTGL is a C++ library. Why would you use "-std=c89" which is for C? Clearly, many C++ features are not part of any C standard. Also, when I compile a C++ program with gcc with this option, I get this warning:

cc1plus: warning: command line option '-std=c90' is valid for C/ObjC but not for C++

ghost commented 3 years ago

I've seen the commit and your discontinuation is understandable. Let this request serve as a reminder for others in case they need the same compatibility.

While it is a C++ library, it still works with a C compiler and I myself use FTGL strictly in C with no C++ capabilities without a problem.

The warning you are seeing is because you are compiling a .cpp file with a C standard. C++ only accepts std=c++98 and others. If you compile a C program the flag will be accepted.

frankheckenbach commented 3 years ago

So don't you have to patch only the C interface headers then?

ghost commented 3 years ago

You would think so, but then take a look at say src/FTCharToGlyphIndexMap.h. At the very bottom of the file after the define there is a single-line comment. Even if nothing in the define is compiled, what comes after it is still read by the pre-processor.

Better to be safe than sorry.

frankheckenbach commented 3 years ago

I suppose you mean after the endif. But the ifndef is just an include guard, so the first time the header is included, the conditional code will be compiled, and it's C++. So I fail to see how a C program can (directly or indirectly) include this header at all.

If it was an "#ifdef cplusplus" instead, I would understand it. Actually, many other headers do have an "#ifdef cplusplus" (the one you mentioned doesn't), so I get it for them, but IMHO only for the code outside of that #ifdef (and gcc seems to agree). It seems strange to me that one must not use C++ comments in the middle of a C++ class.

But anyway, I'm not maintaining FTGL anymore, so you what you want. :)