Changed compiler attribute checking to play nice with older compilers.

This commit is contained in:
harry 2023-01-27 20:38:47 -05:00
parent d4d4001d32
commit a81632b7e1
2 changed files with 24 additions and 8 deletions

View File

@ -11,12 +11,14 @@
#include <cstdio>
#include <cstdlib>
static char *aboutString = 0;
static std::string aboutString;
#ifndef FCEUX_BUILD_TIMESTAMP
#define FCEUX_BUILD_TIMESTAMP __TIME__ " " __DATE__
#endif
//#pragma message( "Compiling using C++ Std: " __FCEU_STRINGIZE(__cplusplus) )
// returns a string suitable for use in an aboutbox
const char *FCEUI_GetAboutString(void)
{
@ -55,14 +57,17 @@ const char *FCEUI_GetAboutString(void)
"\n"
FCEUX_BUILD_TIMESTAMP "\n";
if (aboutString) return aboutString;
if (aboutString.size() > 0) return aboutString.c_str();
const char *compilerString = FCEUD_GetCompilerString();
//allocate the string and concatenate the template with the compiler string
if (!(aboutString = (char*)FCEU_dmalloc(strlen(aboutTemplate) + strlen(compilerString) + 1)))
return NULL;
char cppVersion[128];
sprintf(aboutString,"%s%s",aboutTemplate,compilerString);
return aboutString;
snprintf( cppVersion, sizeof(cppVersion), "\nCompiled using C++ Language Standard: %li\n", __cplusplus);
aboutString.assign( aboutTemplate );
aboutString.append( compilerString );
aboutString.append( cppVersion );
return aboutString.c_str();
}

View File

@ -143,9 +143,20 @@ typedef uint8 (*readfunc)(uint32 A);
#define CTASSERT(x) typedef char __assert ## y[(x) ? 1 : -1];
#endif
#define __FCEU_STRINGIZE2(x) #x
#define __FCEU_STRINGIZE(x) __FCEU_STRINGIZE2(x)
#define FCEU_CPP_HAS_STD(x) ( defined(__cplusplus) && (__cplusplus >= x) )
#ifdef __has_cpp_attribute
#define FCEU_HAS_CPP_ATTRIBUTE(x) __has_cpp_attribute(x)
#else
#define FCEU_HAS_CPP_ATTRIBUTE(x) 0
#endif
#define FCEU_UNUSED(x) (void)(x)
#if __has_cpp_attribute(maybe_unused)
#if FCEU_CPP_HAS_STD(201603L) || FCEU_HAS_CPP_ATTRIBUTE(maybe_unused)
#define FCEU_MAYBE_UNUSED [[maybe_unused]]
#else
#define FCEU_MAYBE_UNUSED