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

Fix 990 / Compilation issues with C++11 and libc++ #993

Merged
merged 4 commits into from
Aug 3, 2018
Merged
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
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ include( CPackVariables )
include( CheckExtraCompilerFeatures )
include( ConfigureSummary )
include( GetTriple )
include( DefaultCompilerFlags )

# get triples arch-vendor-os
get_host_triple( NEST_HOST_TRIPLE NEST_HOST_ARCH NEST_HOST_VENDOR NEST_HOST_OS )
Expand All @@ -134,6 +135,9 @@ get_target_triple( NEST_TARGET_TRIPLE NEST_TARGET_ARCH NEST_TARGET_VENDOR NEST_T
# generate CPackConfig.cmake CPackSourceConfig.cmake files
nest_set_cpack_variables()

# set default compiler flags
nest_set_default_compiler_flags()

# Process the command line arguments
nest_process_with_optimize()
nest_process_with_debug()
Expand Down
26 changes: 26 additions & 0 deletions cmake/DefaultCompilerFlags.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# cmake/DefaultCompilerFlags.cmake
#
# This file is part of NEST.
#
# Copyright (C) 2004 The NEST Initiative
#
# NEST is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# NEST is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with NEST. If not, see <http://www.gnu.org/licenses/>.

# Here all user defined options will be processed.

# set default compiler flags for all compilers
function( NEST_SET_DEFAULT_COMPILER_FLAGS )
# no default flags for C
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11" PARENT_SCOPE )
endfunction()
2 changes: 1 addition & 1 deletion models/aeif_cond_alpha_multisynapse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ aeif_cond_alpha_multisynapse::insert_conductance_recordables( size_t first )
DataAccessFunctor< aeif_cond_alpha_multisynapse >
aeif_cond_alpha_multisynapse::get_data_access_functor( size_t elem )
{
return DataAccessFunctor< aeif_cond_alpha_multisynapse >( this, elem );
return DataAccessFunctor< aeif_cond_alpha_multisynapse >( *this, elem );
}

/* ----------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion models/aeif_cond_beta_multisynapse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ aeif_cond_beta_multisynapse::insert_conductance_recordables( size_t first )
DataAccessFunctor< aeif_cond_beta_multisynapse >
aeif_cond_beta_multisynapse::get_data_access_functor( size_t elem )
{
return DataAccessFunctor< aeif_cond_beta_multisynapse >( this, elem );
return DataAccessFunctor< aeif_cond_beta_multisynapse >( *this, elem );
}

/* ----------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion models/iaf_psc_alpha_multisynapse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ iaf_psc_alpha_multisynapse::insert_current_recordables( size_t first )
DataAccessFunctor< iaf_psc_alpha_multisynapse >
iaf_psc_alpha_multisynapse::get_data_access_functor( size_t elem )
{
return DataAccessFunctor< iaf_psc_alpha_multisynapse >( this, elem );
return DataAccessFunctor< iaf_psc_alpha_multisynapse >( *this, elem );
}

/* ----------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion models/iaf_psc_exp_multisynapse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ iaf_psc_exp_multisynapse::insert_current_recordables( size_t first )
DataAccessFunctor< iaf_psc_exp_multisynapse >
iaf_psc_exp_multisynapse::get_data_access_functor( size_t elem )
{
return DataAccessFunctor< iaf_psc_exp_multisynapse >( this, elem );
return DataAccessFunctor< iaf_psc_exp_multisynapse >( *this, elem );
}

/* ----------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion nestkernel/nest_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ namespace nest

#ifdef HAVE_LONG_LONG
typedef long long tic_t;
#ifdef IS_K
#ifdef LLONG_MAX
const tic_t tic_t_max = LLONG_MAX;
const tic_t tic_t_min = LLONG_MIN;
#else
Expand Down
26 changes: 6 additions & 20 deletions nestkernel/recordables_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,34 +135,20 @@ RecordablesMap< HostNode >::create()
template < typename HostNode >
class DataAccessFunctor
{
// Pointer instead of reference required to avoid problems with
// copying element in std::map when using libc++ under C++11.
HostNode* parent_;
size_t elem_;

public:
DataAccessFunctor( HostNode& n, size_t elem )
: elem_( elem )
{
parent_ = &n;
};

DataAccessFunctor( HostNode* n, size_t elem )
: elem_( elem )
{
parent_ = n;
};
: parent_( &n )
, elem_( elem ){};

double operator()() const
{
return parent_->get_state_element( elem_ );
};

DataAccessFunctor< HostNode >& operator=(
const DataAccessFunctor< HostNode >& other )
{
this->elem_ = other.elem_;
this->parent_ = other.parent_;
return *this;
}
};


Expand All @@ -181,9 +167,9 @@ class DataAccessFunctor
*/
template < typename HostNode >
class DynamicRecordablesMap
: public std::map< Name, const DataAccessFunctor< HostNode > >
: public std::map< Name, DataAccessFunctor< HostNode > >
{
typedef std::map< Name, const DataAccessFunctor< HostNode > > Base_;
typedef std::map< Name, DataAccessFunctor< HostNode > > Base_;

public:
virtual ~DynamicRecordablesMap()
Expand Down