This commit is contained in:
CodeHubUserName 2026-02-07 11:05:10 +01:00 committed by GitHub
commit 2409a0ba92
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 66 additions and 8 deletions

View file

@ -42,6 +42,19 @@ if(SMP)
add_definitions(-D_GLIBCXX_USE_NANOSLEEP) add_definitions(-D_GLIBCXX_USE_NANOSLEEP)
endif(SMP) endif(SMP)
######################################################################################
### MSVC specific compiler options
######################################################################################
if(MSVC)
# Add /Zc:__cplusplus compiler option to enable correct __cplusplus macro
add_compile_options(/Zc:__cplusplus)
# Add utf8
add_compile_options(/utf-8)
# Add HAVE_UINT32_T=1 preprocessor definition
add_definitions(-DHAVE_UINT32_T=1)
endif(MSVC)
###################################################################################### ######################################################################################
### 1) Define installation type ### 1) Define installation type
###################################################################################### ######################################################################################

View file

@ -1,4 +1,4 @@
/** Random number generator adapted from (see comments below) /** Random number generator adapted from (see comments below)
The random number generator is modified into a class The random number generator is modified into a class
by Maarten Keijzer (mak@dhi.dk). Also added the Box-Muller by Maarten Keijzer (mak@dhi.dk). Also added the Box-Muller
@ -37,7 +37,10 @@ Old contact information: todos@geneura.ugr.es, http://geneura.ugr.es
optimization levels so feel free to try your options and see what's best for optimization levels so feel free to try your options and see what's best for
you. you.
*/ */
#if HAVE_UINT32_T
typedef unsigned long uint32_t; typedef unsigned long uint32_t;
#endif // HAVE_UINT32_T
#else #else
#if (! defined __sun) #if (! defined __sun)
// The C99-standard defines uint32_t to be declared in stdint.h, but some // The C99-standard defines uint32_t to be declared in stdint.h, but some

View file

@ -63,7 +63,6 @@ eoCheckPoint<EOT>& do_make_checkpoint(eoParser& _parser, eoState& _state, eoValu
// Signal monitoring // Signal monitoring
//////////////////// ////////////////////
#ifndef _MSC_VER
// the CtrlC monitoring interception // the CtrlC monitoring interception
eoSignal<EOT> *mon_ctrlCCont = nullptr; eoSignal<EOT> *mon_ctrlCCont = nullptr;
eoValueParam<bool>& mon_ctrlCParam = _parser.createParam(false, "monitor-with-CtrlC", "Monitor current generation upon Ctrl C",0, "Stopping criterion"); eoValueParam<bool>& mon_ctrlCParam = _parser.createParam(false, "monitor-with-CtrlC", "Monitor current generation upon Ctrl C",0, "Stopping criterion");
@ -75,7 +74,6 @@ eoCheckPoint<EOT>& do_make_checkpoint(eoParser& _parser, eoState& _state, eoValu
// add to checkpoint // add to checkpoint
checkpoint->add(*mon_ctrlCCont); checkpoint->add(*mon_ctrlCCont);
} }
#endif
/////////////////// ///////////////////
// Counters // Counters

View file

@ -1,4 +1,4 @@
/* /*
* C++ification of Nikolaus Hansen's original C-source code for the * C++ification of Nikolaus Hansen's original C-source code for the
* CMA-ES * CMA-ES
* *
@ -66,7 +66,8 @@ using namespace std;
namespace eo { namespace eo {
struct CMAStateImpl { class CMAStateImpl {
public:
CMAParams p; CMAParams p;

View file

@ -1,4 +1,4 @@
/** Random number generator adapted from (see comments below) /** Random number generator adapted from (see comments below)
The random number generator is modified into a class The random number generator is modified into a class
by Maarten Keijzer (mak@dhi.dk). Also added the Box-Muller by Maarten Keijzer (mak@dhi.dk). Also added the Box-Muller
@ -37,7 +37,12 @@ Old contact information: todos@geneura.ugr.es, http://geneura.ugr.es
optimization levels so feel free to try your options and see what's best for optimization levels so feel free to try your options and see what's best for
you. you.
*/ */
#if HAVE_UINT32_T
#include <cstdint>
#else
typedef unsigned long uint32_t; typedef unsigned long uint32_t;
#endif // HAVE_UINT32_T
#else #else
#if (! defined __sun) #if (! defined __sun)
// The C99-standard defines uint32_t to be declared in stdint.h, but some // The C99-standard defines uint32_t to be declared in stdint.h, but some

View file

@ -33,6 +33,11 @@
#include <map> #include <map>
#include <vector> #include <vector>
#ifdef _WINDOWS
#define NOMINMAX
#include <Windows.h>
#endif // _WINDOWS
/** /**
* @addtogroup Continuators * @addtogroup Continuators
* @{ * @{
@ -40,6 +45,25 @@
extern std::map< int, bool > signals_called; extern std::map< int, bool > signals_called;
#ifdef _WINDOWS
// Windows console control handler - process level handler
// Returns TRUE if the signal was handled, FALSE otherwise
inline BOOL WINAPI ConsoleCtrlHandler(DWORD dwCtrlType)
{
if (dwCtrlType == CTRL_C_EVENT || dwCtrlType == CTRL_BREAK_EVENT)
{
// Map Windows control event to SIGINT for compatibility
::signals_called[SIGINT] = true;
eo::log << eo::logging << "Signal wished…" << std::endl;
return TRUE; // Signal handled, don't terminate the process
}
return FALSE;
}
// Track if console handler is already installed
static bool console_handler_installed = false;
#endif // _WINDOWS
/** eoSignal inherits from eoCheckPoint including signals handling (see signal(7)) /** eoSignal inherits from eoCheckPoint including signals handling (see signal(7))
* *
* @ingroup Utilities * @ingroup Utilities
@ -53,7 +77,14 @@ public :
{ {
::signals_called[_sig] = false; ::signals_called[_sig] = false;
#ifndef _WINDOWS #ifdef _WINDOWS
// Install Windows console control handler (only once per process)
if (!console_handler_installed)
{
SetConsoleCtrlHandler(ConsoleCtrlHandler, TRUE);
console_handler_installed = true;
}
#else
#ifdef SIGQUIT #ifdef SIGQUIT
::signal( _sig, handler ); ::signal( _sig, handler );
#endif // !SIGQUIT #endif // !SIGQUIT
@ -64,7 +95,14 @@ public :
{ {
::signals_called[_sig] = false; ::signals_called[_sig] = false;
#ifndef _WINDOWS #ifdef _WINDOWS
// Install Windows console control handler (only once per process)
if (!console_handler_installed)
{
SetConsoleCtrlHandler(ConsoleCtrlHandler, TRUE);
console_handler_installed = true;
}
#else
#ifdef SIGQUIT #ifdef SIGQUIT
::signal( _sig, handler ); ::signal( _sig, handler );
#endif // !SIGQUIT #endif // !SIGQUIT