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

make ege compatible with clang #122

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ if (MSVC)
message(STATUS "${TARGET_BITS}bit MSVC target: MSVC ${MSVC_VERSION}")
elseif (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
message(STATUS "${TARGET_BITS}bit GNU target: GCC ${CMAKE_C_COMPILER_VERSION}")
elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
message(STATUS "${TARGET_BITS}bit Clang target: Clang ${CMAKE_C_COMPILER_VERSION}")
else ()
if (CMAKE_CXX_COMPILER_ID)
message(FATAL_ERROR "Unsupported compiler: ${CMAKE_CXX_COMPILER_ID}")
Expand All @@ -37,6 +39,9 @@ macro(ege_add_executable name source)
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
target_link_options(${name}
PRIVATE -mwindows)
elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
target_link_options(${name}
PRIVATE -mwindows)
endif ()
endmacro()

Expand Down
5 changes: 5 additions & 0 deletions src/ege_head.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@
# endif
# define COMPILER_VER MSVC_VER SYSBITS
# define COMPILER_VER_W EGE_L(MSVC_VER) SYSBITS_W
#elif defined(__clang__)
# define COMPILER_VER "Clang" __clang_version__ SYSBITS
# define COMPILER_VER_W L"Clang" EGE_L(__clang_version__) SYSBITS_W
#else
# define GCC_VER EGE_TOSTR(__GNUC__) "." EGE_TOSTR(__GNUC_MINOR__)
# define GCC_VER_W EGE_L(EGE_TOSTR(__GNUC__)) L"." EGE_L(EGE_TOSTR(__GNUC_MINOR__))
Expand All @@ -78,11 +81,13 @@

// MSVC 从 10.0(VS2010)开始有 stdint.h
// GCC 从 4.5 开始有 stdint.h
#ifndef __clang__
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里改成在第 85 行加上 || defined(__clang__)

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

改改然后合入了?

#if _MSC_VER >= 1600 || __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)
# include <stdint.h>
#elif !defined(_MSC_VER) || _MSC_VER > 1300
# include "stdint.h"
#endif
#endif

#include <string>

Expand Down
4 changes: 4 additions & 0 deletions src/graphics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,18 @@ static int g_initoption = INIT_DEFAULT;
static HWND g_attach_hwnd = 0;
static WNDPROC DefWindowProcFunc = NULL;

#ifndef __clang__
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这段为啥要改,应该没问题啊。
也可以把判断 __cplusplus 的部分去掉。

#ifdef __cplusplus
extern "C" {
#endif
#endif
char* getlogodata();
unsigned long getlogodatasize();
#ifndef __clang__
#ifdef __cplusplus
}
#endif
#endif

float EGE_PRIVATE_GetFPS(int add);
DWORD WINAPI messageloopthread(LPVOID lpParameter);
Expand Down
5 changes: 5 additions & 0 deletions src/logo.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
#ifndef __clang__
#ifdef __cplusplus
extern "C"
{
#endif
#else
namespace ege {
#endif
static unsigned char logo_res[] = {
255,216,255,224,0,16,74,70,73,70,0,1,1,1,0,96,
0,96,0,0,255,225,3,82,69,120,105,102,0,0,77,77,
Expand Down Expand Up @@ -979,6 +983,7 @@ unsigned long getlogodatasize() {
char* getlogodata() {
return (char*)logo_res;
}

#ifdef __cplusplus
}
#endif