Skip to content

Commit 1ae5c23

Browse files
committed
Implement required code changes for common target to compile as C++
* Add casts where necessary mostly for void * -> any other type * Replaced use of min, max, swap macros with std variant * Fixed where `const char` strings were passed/stored to non-const variables * Updated VECTOR_RESIZE with C++ variant that relays on decltype to make type safe cast from memory manager
1 parent eae53ec commit 1ae5c23

49 files changed

Lines changed: 455 additions & 169 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

3rdparty/mt19937ar/mt19937ar.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@
4343
email: m-mat @ math.sci.hiroshima-u.ac.jp (remove space)
4444
*/
4545

46+
#ifdef __cplusplus
47+
extern "C" {
48+
#endif
49+
4650
/* initializes mt[N] with a seed */
4751
void init_genrand(unsigned long s);
4852

@@ -70,3 +74,7 @@ double genrand_real3(void);
7074

7175
/* generates a random number on [0,1) with 53-bit resolution*/
7276
double genrand_res53(void);
77+
78+
#ifdef __cplusplus
79+
}
80+
#endif

CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ project(hercules LANGUAGES C CXX)
2424
set(CMAKE_C_STANDARD 11)
2525
set(CMAKE_C_STANDARD_REQUIRED ON)
2626
set(CMAKE_C_EXTENSIONS ON)
27+
set(CMAKE_CXX_STANDARD 20)
28+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
29+
set(CMAKE_CXX_EXTENSIONS NO)
2730
set(CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE BOOL "Enable compile commands" FORCE)
2831
if(NOT CMAKE_SYSTEM_NAME STREQUAL "Windows")
2932
set(CMAKE_INSTALL_LIBDIR "lib")
@@ -164,7 +167,7 @@ if(MSVC)
164167
add_compile_options(/wd4100) # Disable unused parameter warning mostly due to BUILDIN and similar functions having unused parameters
165168
add_compile_options(/wd4312) # Disable conversion to greater size warning (see 0xdeadbeef pointers)
166169
# Definations
167-
add_compile_definitions(WIN32 _WIN32 __WIN32 _CRT_SECURE_NO_DEPRECATE _CRT_NONSTDC_NO_DEPRECATE FD_SETSIZE=4096 WIN32_LEAN_AND_MEAN)
170+
add_compile_definitions(WIN32 _WIN32 __WIN32 _CRT_SECURE_NO_DEPRECATE _CRT_NONSTDC_NO_DEPRECATE FD_SETSIZE=4096 WIN32_LEAN_AND_MEAN NOMINMAX)
168171
else()
169172
# Check for mandatory compile flags
170173
include(CompilerFlagHelpers)

src/common/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,3 +164,5 @@ if(NOT CMAKE_SYSTEM_NAME STREQUAL "Windows")
164164

165165
add_dependencies(common sysinfo)
166166
endif()
167+
168+
set_source_files_properties(${COMMON_SRCS} PROPERTIES LANGUAGE CXX)

src/common/HPM.c

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ static void *hplugin_import_symbol(char *name, unsigned int pID)
111111
if (i != VECTOR_LENGTH(HPM->symbols))
112112
return VECTOR_INDEX(HPM->symbols, i)->ptr;
113113

114-
ShowError("HPM:get_symbol:%s: '"CL_WHITE"%s"CL_RESET"' not found!\n",HPM->pid2name(pID),name);
114+
ShowError("HPM:get_symbol:%s: '" CL_WHITE "%s" CL_RESET "' not found!\n",HPM->pid2name(pID),name);
115115
return NULL;
116116
}
117117

@@ -243,11 +243,11 @@ static bool hplugin_data_store_validate(enum HPluginDataTypes type, struct hplug
243243
case HPDT_UNIT_PARAMETER:
244244
default:
245245
if (HPM->data_store_validate_sub == NULL) {
246-
ShowError("HPM:validateHPData failed, type %u needs sub-handler!\n", type);
246+
ShowError("HPM:validateHPData failed, type %u needs sub-handler!\n", (unsigned int)type);
247247
return false;
248248
}
249249
if (!HPM->data_store_validate_sub(type, storeptr, initialize)) {
250-
ShowError("HPM:HPM:validateHPData failed, unknown type %u!\n", type);
250+
ShowError("HPM:HPM:validateHPData failed, unknown type %u!\n", (unsigned int)type);
251251
return false;
252252
}
253253
break;
@@ -257,7 +257,7 @@ static bool hplugin_data_store_validate(enum HPluginDataTypes type, struct hplug
257257
store = *storeptr;
258258
}
259259
if (store->type != type) {
260-
ShowError("HPM:HPM:validateHPData failed, store type mismatch %u != %u.\n", store->type, type);
260+
ShowError("HPM:HPM:validateHPData failed, store type mismatch %u != %u.\n", (unsigned int)store->type, (unsigned int)type);
261261
return false;
262262
}
263263
return true;
@@ -282,7 +282,7 @@ static void hplugins_addToHPData(enum HPluginDataTypes type, uint32 pluginID, st
282282

283283
if (!HPM->data_store_validate(type, storeptr, true)) {
284284
/* woo it failed! */
285-
ShowError("HPM:addToHPData:%s: failed, type %u (%u|%u)\n", HPM->pid2name(pluginID), type, pluginID, classid);
285+
ShowError("HPM:addToHPData:%s: failed, type %u (%u|%u)\n", HPM->pid2name(pluginID), (unsigned int)type, pluginID, classid);
286286
return;
287287
}
288288
store = *storeptr;
@@ -324,7 +324,7 @@ static void *hplugins_getFromHPData(enum HPluginDataTypes type, uint32 pluginID,
324324

325325
if (!HPM->data_store_validate(type, &store, false)) {
326326
/* woo it failed! */
327-
ShowError("HPM:getFromHPData:%s: failed, type %u (%u|%u)\n", HPM->pid2name(pluginID), type, pluginID, classid);
327+
ShowError("HPM:getFromHPData:%s: failed, type %u (%u|%u)\n", HPM->pid2name(pluginID), (unsigned int)type, pluginID, classid);
328328
return NULL;
329329
}
330330
if (!store)
@@ -352,7 +352,7 @@ static void hplugins_removeFromHPData(enum HPluginDataTypes type, uint32 pluginI
352352

353353
if (!HPM->data_store_validate(type, &store, false)) {
354354
/* woo it failed! */
355-
ShowError("HPM:removeFromHPData:%s: failed, type %u (%u|%u)\n", HPM->pid2name(pluginID), type, pluginID, classid);
355+
ShowError("HPM:removeFromHPData:%s: failed, type %u (%u|%u)\n", HPM->pid2name(pluginID), (unsigned int)type, pluginID, classid);
356356
return;
357357
}
358358
if (!store)
@@ -451,7 +451,7 @@ static bool hplugins_addconf(unsigned int pluginID, enum HPluginConfType type, c
451451
}
452452

453453
if (type >= HPCT_MAX) {
454-
ShowError("HPM->addConf:%s: unknown point '%u' specified for config '%s'\n",HPM->pid2name(pluginID),type,name);
454+
ShowError("HPM->addConf:%s: unknown point '%u' specified for config '%s'\n", HPM->pid2name(pluginID), (unsigned int)type, name);
455455
return false;
456456
}
457457

@@ -494,20 +494,20 @@ static struct hplugin *hplugin_load(const char *filename)
494494
const char *(*HPMLoadEvent)(int server_type);
495495

496496
if( HPM->exists(filename) ) {
497-
ShowWarning("HPM:plugin_load: attempting to load duplicate '"CL_WHITE"%s"CL_RESET"', skipping...\n", filename);
497+
ShowWarning("HPM:plugin_load: attempting to load duplicate '" CL_WHITE "%s" CL_RESET "', skipping...\n", filename);
498498
return NULL;
499499
}
500500

501501
plugin = HPM->create();
502502

503503
if (!(plugin->dll = plugin_open(filename))) {
504504
char buf[1024];
505-
ShowFatalError("HPM:plugin_load: failed to load '"CL_WHITE"%s"CL_RESET"' (error: %s)!\n", filename, plugin_geterror(buf));
505+
ShowFatalError("HPM:plugin_load: failed to load '" CL_WHITE "%s" CL_RESET "' (error: %s)!\n", filename, plugin_geterror(buf));
506506
exit(EXIT_FAILURE);
507507
}
508508

509509
if( !( info = plugin_import(plugin->dll, "pinfo",struct hplugin_info*) ) ) {
510-
ShowFatalError("HPM:plugin_load: failed to retrieve 'plugin_info' for '"CL_WHITE"%s"CL_RESET"'!\n", filename);
510+
ShowFatalError("HPM:plugin_load: failed to retrieve 'plugin_info' for '" CL_WHITE "%s" CL_RESET "'!\n", filename);
511511
exit(EXIT_FAILURE);
512512
}
513513

@@ -517,27 +517,27 @@ static struct hplugin *hplugin_load(const char *filename)
517517
}
518518

519519
if( !HPM->iscompatible(info->req_version) ) {
520-
ShowFatalError("HPM:plugin_load: '"CL_WHITE"%s"CL_RESET"' incompatible version '%s' -> '%s'!\n", filename, info->req_version, HPM_VERSION);
520+
ShowFatalError("HPM:plugin_load: '" CL_WHITE "%s" CL_RESET "' incompatible version '%s' -> '%s'!\n", filename, info->req_version, HPM_VERSION);
521521
exit(EXIT_FAILURE);
522522
}
523523

524524
plugin->info = info;
525525
plugin->filename = aStrdup(filename);
526526

527527
if ((import_symbol_ref = plugin_import(plugin->dll, "import_symbol", ImportSymbolFunc **)) == NULL) {
528-
ShowFatalError("HPM:plugin_load: failed to retrieve 'import_symbol' for '"CL_WHITE"%s"CL_RESET"'!\n", filename);
528+
ShowFatalError("HPM:plugin_load: failed to retrieve 'import_symbol' for '" CL_WHITE "%s" CL_RESET "'!\n", filename);
529529
exit(EXIT_FAILURE);
530530
}
531531

532532
*import_symbol_ref = HPM->import_symbol;
533533

534534
if( !( HPMi = plugin_import(plugin->dll, "HPMi",struct HPMi_interface **) ) ) {
535-
ShowFatalError("HPM:plugin_load: failed to retrieve 'HPMi' for '"CL_WHITE"%s"CL_RESET"'!\n", filename);
535+
ShowFatalError("HPM:plugin_load: failed to retrieve 'HPMi' for '" CL_WHITE "%s" CL_RESET "'!\n", filename);
536536
exit(EXIT_FAILURE);
537537
}
538538

539539
if( !( *HPMi = plugin_import(plugin->dll, "HPMi_s",struct HPMi_interface *) ) ) {
540-
ShowFatalError("HPM:plugin_load: failed to retrieve 'HPMi_s' for '"CL_WHITE"%s"CL_RESET"'!\n", filename);
540+
ShowFatalError("HPM:plugin_load: failed to retrieve 'HPMi_s' for '" CL_WHITE "%s" CL_RESET "'!\n", filename);
541541
exit(EXIT_FAILURE);
542542
}
543543
plugin->hpi = *HPMi;
@@ -558,40 +558,40 @@ static struct hplugin *hplugin_load(const char *filename)
558558
anyEvent = true;
559559

560560
if( !anyEvent ) {
561-
ShowWarning("HPM:plugin_load: no events found for '"CL_WHITE"%s"CL_RESET"'!\n", filename);
561+
ShowWarning("HPM:plugin_load: no events found for '" CL_WHITE "%s" CL_RESET "'!\n", filename);
562562
exit(EXIT_FAILURE);
563563
}
564564

565565
if (!(HPMLoadEvent = plugin_import(plugin->dll, "HPM_shared_symbols", const char *(*)(int)))) {
566-
ShowFatalError("HPM:plugin_load: failed to retrieve 'HPM_shared_symbols' for '"CL_WHITE"%s"CL_RESET"', most likely not including HPMDataCheck.h!\n", filename);
566+
ShowFatalError("HPM:plugin_load: failed to retrieve 'HPM_shared_symbols' for '" CL_WHITE "%s" CL_RESET "', most likely not including HPMDataCheck.h!\n", filename);
567567
exit(EXIT_FAILURE);
568568
}
569569
{
570570
const char *failure = HPMLoadEvent(SERVER_TYPE);
571571
if (failure) {
572-
ShowFatalError("HPM:plugin_load: failed to import symbol '%s' into '"CL_WHITE"%s"CL_RESET"'.\n", failure, filename);
572+
ShowFatalError("HPM:plugin_load: failed to import symbol '%s' into '" CL_WHITE "%s" CL_RESET "'.\n", failure, filename);
573573
exit(EXIT_FAILURE);
574574
}
575575
}
576576

577577
if( !( HPMDataCheckLen = plugin_import(plugin->dll, "HPMDataCheckLen", unsigned int *) ) ) {
578-
ShowFatalError("HPM:plugin_load: failed to retrieve 'HPMDataCheckLen' for '"CL_WHITE"%s"CL_RESET"', most likely not including HPMDataCheck.h!\n", filename);
578+
ShowFatalError("HPM:plugin_load: failed to retrieve 'HPMDataCheckLen' for '" CL_WHITE "%s" CL_RESET "', most likely not including HPMDataCheck.h!\n", filename);
579579
exit(EXIT_FAILURE);
580580
}
581581

582582
if( !( HPMDataCheckVer = plugin_import(plugin->dll, "HPMDataCheckVer", int *) ) ) {
583-
ShowFatalError("HPM:plugin_load: failed to retrieve 'HPMDataCheckVer' for '"CL_WHITE"%s"CL_RESET"', most likely an outdated plugin!\n", filename);
583+
ShowFatalError("HPM:plugin_load: failed to retrieve 'HPMDataCheckVer' for '" CL_WHITE "%s" CL_RESET "', most likely an outdated plugin!\n", filename);
584584
exit(EXIT_FAILURE);
585585
}
586586

587587
if( !( HPMDataCheck = plugin_import(plugin->dll, "HPMDataCheck", struct s_HPMDataCheck *) ) ) {
588-
ShowFatalError("HPM:plugin_load: failed to retrieve 'HPMDataCheck' for '"CL_WHITE"%s"CL_RESET"', most likely not including HPMDataCheck.h!\n", filename);
588+
ShowFatalError("HPM:plugin_load: failed to retrieve 'HPMDataCheck' for '" CL_WHITE "%s" CL_RESET "', most likely not including HPMDataCheck.h!\n", filename);
589589
exit(EXIT_FAILURE);
590590
}
591591

592592
// TODO: Remove the HPM->DataCheck != NULL check once login and char support is complete
593593
if (HPM->DataCheck != NULL && !HPM->DataCheck(HPMDataCheck,*HPMDataCheckLen,*HPMDataCheckVer,plugin->info->name)) {
594-
ShowFatalError("HPM:plugin_load: '"CL_WHITE"%s"CL_RESET"' failed DataCheck, out of sync from the core (recompile plugin)!\n", filename);
594+
ShowFatalError("HPM:plugin_load: '" CL_WHITE "%s" CL_RESET "' failed DataCheck, out of sync from the core (recompile plugin)!\n", filename);
595595
exit(EXIT_FAILURE);
596596
}
597597

@@ -617,7 +617,7 @@ static struct hplugin *hplugin_load(const char *filename)
617617
if( HPM->load_sub )
618618
HPM->load_sub(plugin);
619619

620-
ShowStatus("HPM: Loaded plugin '"CL_WHITE"%s"CL_RESET"' (%s)%s.\n",
620+
ShowStatus("HPM: Loaded plugin '" CL_WHITE "%s" CL_RESET "' (%s)%s.\n",
621621
plugin->info->name, plugin->info->version,
622622
plugin->hpi->hooking != NULL ? " built with HPMHooking support" : "");
623623

@@ -725,7 +725,7 @@ static void hplugins_config_read(void)
725725
&& (addhook_sub = plugin_import(plugin->dll, "HPM_Plugin_AddHook",bool (*)(enum HPluginHookType, const char *, void *, unsigned int))) != NULL) {
726726
const char *failed = func(&HPM->hooking->force_return);
727727
if (failed) {
728-
ShowError("HPM: failed to retrieve '%s' for '"CL_WHITE"%s"CL_RESET"'!\n", failed, plugin_name);
728+
ShowError("HPM: failed to retrieve '%s' for '" CL_WHITE "%s" CL_RESET "'!\n", failed, plugin_name);
729729
} else {
730730
HPM->hooking->enabled = true;
731731
HPM->hooking->addhook_sub = addhook_sub;
@@ -747,7 +747,7 @@ static void hplugins_config_read(void)
747747
aFree(base_path);
748748

749749
if (VECTOR_LENGTH(HPM->plugins))
750-
ShowStatus("HPM: There are '"CL_WHITE"%d"CL_RESET"' plugins loaded, type '"CL_WHITE"plugins"CL_RESET"' to list them\n", VECTOR_LENGTH(HPM->plugins));
750+
ShowStatus("HPM: There are '" CL_WHITE "%d" CL_RESET "' plugins loaded, type '" CL_WHITE "plugins" CL_RESET "' to list them\n", VECTOR_LENGTH(HPM->plugins));
751751
}
752752

753753
/**
@@ -766,11 +766,11 @@ static CPCMD(plugins)
766766
return;
767767
}
768768

769-
ShowInfo("HPC: There are '"CL_WHITE"%d"CL_RESET"' plugins loaded\n", VECTOR_LENGTH(HPM->plugins));
769+
ShowInfo("HPC: There are '" CL_WHITE "%d" CL_RESET "' plugins loaded\n", VECTOR_LENGTH(HPM->plugins));
770770

771771
for(i = 0; i < VECTOR_LENGTH(HPM->plugins); i++) {
772772
struct hplugin *plugin = VECTOR_INDEX(HPM->plugins, i);
773-
ShowInfo("HPC: - '"CL_WHITE"%s"CL_RESET"' (%s)\n", plugin->info->name, plugin->filename);
773+
ShowInfo("HPC: - '" CL_WHITE "%s" CL_RESET "' (%s)\n", plugin->info->name, plugin->filename);
774774
}
775775
}
776776

@@ -815,7 +815,7 @@ static unsigned char hplugins_parse_packets(int fd, int packet_id, enum HPluginP
815815
* @retval "core" if the plugin ID belongs to the Hercules core.
816816
* @retval "UnknownPlugin" if the plugin wasn't found.
817817
*/
818-
static char *hplugins_id2name(unsigned int pid)
818+
static const char *hplugins_id2name(unsigned int pid)
819819
{
820820
int i;
821821

@@ -852,7 +852,7 @@ static const char *HPM_file2ptr(const char *file)
852852
}
853853

854854
/* we handle this memory outside of the server's memory manager because we need it to exist after the memory manager goes down */
855-
HPM->filenames.data = realloc(HPM->filenames.data, (++HPM->filenames.count)*sizeof(struct HPMFileNameCache));
855+
HPM->filenames.data = (struct HPMFileNameCache *)realloc(HPM->filenames.data, (++HPM->filenames.count)*sizeof(struct HPMFileNameCache));
856856

857857
HPM->filenames.data[i].addr = file;
858858
HPM->filenames.data[i].name = strdup(file);

src/common/HPM.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ struct HPM_interface {
155155
void (*share) (void *value, const char *name);
156156
void (*config_read) (void);
157157
bool (*parse_battle_conf) (const struct config_t *config, const char *filename, bool imported);
158-
char *(*pid2name) (unsigned int pid);
158+
const char *(*pid2name) (unsigned int pid);
159159
unsigned char (*parse_packets) (int fd, int packet_id, enum HPluginPacketHookingPoints point);
160160
void (*load_sub) (struct hplugin *plugin);
161161
/* for custom config parsing */
@@ -177,10 +177,18 @@ struct HPM_interface {
177177
struct HPMHooking_core_interface *hooking;
178178
};
179179

180+
#ifdef __cplusplus
181+
extern "C" {
182+
#endif
183+
180184
CMDLINEARG(loadplugin);
181185

182186
extern struct HPM_interface *HPM;
183187

184188
void hpm_defaults(void);
185189

190+
#ifdef __cplusplus
191+
}
192+
#endif
193+
186194
#endif /* COMMON_HPM_H */

src/common/HPMi.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ struct HPMi_interface {
233233
void (*event[HPET_MAX]) (void);
234234
bool (*addCommand) (char *name, bool (*func)(const int fd, struct map_session_data* sd, const char* command, const char* message,struct AtCommandInfo *info));
235235
bool (*addScript) (char *name, char *args, bool (*func)(struct script_state *st), bool isDeprecated);
236-
void (*addCPCommand) (char *name, CParseFunc func);
236+
void (*addCPCommand) (const char *name, CParseFunc func);
237237
/* HPM Custom Data */
238238
void (*addToHPData) (enum HPluginDataTypes type, uint32 pluginID, struct hplugin_data_store **storeptr, void *data, uint32 classid, bool autofree);
239239
void *(*getFromHPData) (enum HPluginDataTypes type, uint32 pluginID, struct hplugin_data_store *store, uint32 classid);

src/common/atomic.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@
3838

3939
#if _MSC_VER < 1800
4040
#if !defined(_M_X64)
41+
42+
#ifdef __cplusplus
43+
extern "C" {
44+
#endif
45+
4146
// When compiling for windows 32bit, the 8byte interlocked operations are not provided by Microsoft
4247
// (because they need at least i586 so its not generic enough.. ... )
4348
forceinline int64 InterlockedCompareExchange64(volatile int64 *dest, int64 exch, int64 _cmp){
@@ -93,6 +98,10 @@ forceinline volatile int64 InterlockedExchange64(volatile int64 *target, int64 v
9398
return old;
9499
}
95100

101+
#ifdef __cplusplus
102+
}
103+
#endif
104+
96105
#else // _M_X64
97106
#define InterlockedExchange(_Target, _Value) _InterlockedExchange((_Target), (_Value))
98107
#define InterlockedCompareExchange(_Destination, _ExChange, _Comperand) _InterlockedCompareExchange((_Destination), (_ExChange), (_Comperand))
@@ -110,6 +119,10 @@ forceinline volatile int64 InterlockedExchange64(volatile int64 *target, int64 v
110119
#error Target platform currently not supported
111120
#endif
112121

122+
#ifdef __cplusplus
123+
extern "C" {
124+
#endif
125+
113126
static forceinline int64 InterlockedExchangeAdd64(volatile int64 *addend, int64 increment){
114127
return __sync_fetch_and_add(addend, increment);
115128
}//end: InterlockedExchangeAdd64()
@@ -151,6 +164,10 @@ static forceinline int32 InterlockedExchange(volatile int32 *target, int32 val){
151164
return __sync_lock_test_and_set(target, val);
152165
}//end: InterlockedExchange()
153166

167+
#ifdef __cplusplus
168+
}
169+
#endif
170+
154171
#endif // !defined(__MINGW32__) && !defined(MINGW)
155172

156173
#endif //endif compiler decision

src/common/base62.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,18 @@ struct base62_interface {
3434
bool (*encode_int_padded) (int value, char *buf, int min_len, int buf_len);
3535
};
3636

37+
#ifdef __cplusplus
38+
extern "C" {
39+
#endif
40+
3741
#ifdef HERCULES_CORE
3842
void base62_defaults(void);
3943
#endif // HERCULES_CORE
4044

4145
HPShared struct base62_interface *base62;
4246

47+
#ifdef __cplusplus
48+
}
49+
#endif
50+
4351
#endif // COMMON_BASE62_H

src/common/cbasetypes.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,6 @@ typedef uintptr_t uintptr;
282282
// keyword replacement
283283
#ifdef _MSC_VER
284284
// For MSVC (windows)
285-
#define inline __inline
286285
#define forceinline __forceinline
287286
#define ra_align(n) __declspec(align(n))
288287
#else
@@ -383,6 +382,7 @@ typedef char bool;
383382
//////////////////////////////////////////////////////////////////////////
384383
// macro tools
385384

385+
#ifndef __cplusplus
386386
#ifdef swap // just to be sure
387387
#undef swap
388388
#endif
@@ -403,6 +403,7 @@ typedef char bool;
403403
#ifndef min
404404
#define min(a,b) (((a) < (b)) ? (a) : (b))
405405
#endif
406+
#endif
406407

407408
//////////////////////////////////////////////////////////////////////////
408409
// should not happen

0 commit comments

Comments
 (0)