JACoders / OpenJK

Community effort to maintain and improve Jedi Academy (SP & MP) + Jedi Outcast (SP only) released by Raven Software
GNU General Public License v2.0
2.03k stars 614 forks source link

SP won't compile on C++14 #651

Closed eezstreet closed 9 years ago

eezstreet commented 9 years ago

Due to changes with string literals in C++14, the compile will fail.

error C3688: invalid literal suffix 'S_COLOR_GREY'; literal operator or literal operator template 'operator ""S_COLOR_GREY' not found cvar.cpp:1013

Here's a sample of one of the lines: Com_Printf( S_COLOR_GREY"Bind "S_COLOR_WHITE"%s = "S_COLOR_GREY"\""S_COLOR_WHITE"%s"S_COLOR_GREY"\""S_COLOR_WHITE"\n", Key_KeynumToString( b ), kg.keys[b].binding );

Razish commented 9 years ago

This is the case in C++11 as-well.

ensiform commented 9 years ago

And likely also applies to MP's version of the file too.

Razish commented 9 years ago

I'm sure I already fixed a bunch.

smcv commented 9 years ago

Due to a recent addition of #include <cstdint> (which is a C++11 feature) I'm now compiling with -std=gnu++11 (C++11 with GNU extensions) on gcc, leading to a similar issue there, although on gcc it's currently a warning rather than a hard error. I think #658 fixes all the instances of this, although there could be some left in MSVC- or Windows-specific code.

ensiform commented 9 years ago

We require VS2010 to compile, therefore (c)stdint(.h) is included.

smcv commented 9 years ago

Specifically, https://github.com/smcv/OpenJK/commit/5d2fd21593bf20b958563adbfe360f6890d21d36 should fix most or all of this bug. I haven't tested MSVC, Windows or Mac builds, so I can't be sure that all instances are fixed, but the Linux build works (in g++'s C++11 mode) with that branch applied.

We require VS2010 to compile, therefore (c)stdint(.h) is included.

I'm not saying that MSVC doesn't have cstdint. However, Linux and Mac builds require either g++ or clang. g++ (gcc c++) does have cstdint, but in C++98 mode, it issues a compiler error if you use it. gcc in C++11 mode does allow using it (because cstdint is part of the C++11 standard), which is why I switched it into C++11 mode for #658.

If you would prefer that part of #658 to be fixed by changing #include <cstdint> to #include <stdint.h> instead of switching to C++11, I can do that. However, fixing the string concatenation syntax (this bug) seems like something that will eventually be necessary anyway, because future versions of MSVC and/or g++ will probably change their default C++ standards-compliance mode from C++98 to C++11 (or newer).

smcv commented 9 years ago

And likely also applies to MP's version of the file too.

You are correct, this applies to both SP and MP (but seemingly not JK2).