-
Notifications
You must be signed in to change notification settings - Fork 412
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix for systems that don't allow definitions of stl containers with i…
…ncomplete types Definitions of stl containers with incomplete type definitions, e.g. by means of forward declarations, results in undefined behavior according to the c++ standard. This corrects the problem by using providing an alternative implementation using smart pointers selectable at configure time by the user.
- Loading branch information
Showing
9 changed files
with
239 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# - Macro to check whether the STL containers support incomplete types | ||
# The issue at stake is discussed here in depth: | ||
# http://www.drdobbs.com/the-standard-librarian-containers-of-inc/184403814 | ||
# | ||
# Empirically libstdc++ and MSVC++ support containers of incomplete types | ||
# whereas libc++ does not. | ||
# | ||
# The result is returned in HAVE_STL_CONTAINER_INCOMPLETE_TYPES | ||
# | ||
# Copyright 2014 Brian Jensen <Jensen dot J dot Brian at gmail dot com> | ||
# Author: Brian Jensen <Jensen dot J dot Brian at gmail dot com> | ||
# | ||
|
||
macro(CHECK_STL_CONTAINERS) | ||
INCLUDE(CheckCXXSourceCompiles) | ||
SET(CMAKE_REQUIRED_FLAGS) | ||
CHECK_CXX_SOURCE_COMPILES(" | ||
#include <string> | ||
#include <map> | ||
#include <vector> | ||
class TreeElement; | ||
typedef std::map<std::string, TreeElement> SegmentMap; | ||
class TreeElement | ||
{ | ||
TreeElement(const std::string& name): number(0) {} | ||
public: | ||
int number; | ||
SegmentMap::const_iterator parent; | ||
std::vector<SegmentMap::const_iterator> children; | ||
static TreeElement Root(std::string& name) | ||
{ | ||
return TreeElement(name); | ||
} | ||
}; | ||
int main() | ||
{ | ||
return 0; | ||
} | ||
" | ||
HAVE_STL_CONTAINER_INCOMPLETE_TYPES) | ||
|
||
endmacro(CHECK_STL_CONTAINERS) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// Copyright (C) 2014 Ruben Smits <ruben dot smits at mech dot kuleuven dot be> | ||
|
||
// Version: 1.0 | ||
// Author: Brian Jensen <Jensen dot J dot Brian at gmail dot com> | ||
// Maintainer: Ruben Smits <ruben dot smits at mech dot kuleuven dot be> | ||
// URL: http://www.orocos.org/kdl | ||
|
||
// This library is free software; you can redistribute it and/or | ||
// modify it under the terms of the GNU Lesser General Public | ||
// License as published by the Free Software Foundation; either | ||
// version 2.1 of the License, or (at your option) any later version. | ||
|
||
// This library 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 | ||
// Lesser General Public License for more details. | ||
|
||
// You should have received a copy of the GNU Lesser General Public | ||
// License along with this library; if not, write to the Free Software | ||
// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
|
||
#ifndef KDL_CONFIG_H | ||
#define KDL_CONFIG_H | ||
|
||
#define KDL_VERSION_MAJOR @KDL_VERSION_MAJOR@ | ||
#define KDL_VERSION_MINOR @KDL_VERSION_MINOR@ | ||
#define KDL_VERSION_PATCH @KDL_VERSION_PATCH@ | ||
|
||
#define KDL_VERSION (KDL_VERSION_MAJOR << 16) | (KDL_VERSION_MINOR << 8) | KDL_VERSION_PATCH | ||
|
||
#define KDL_VERSION_STRING "@KDL_VERSION@" | ||
|
||
//Set which version of the Tree Interface to use | ||
#cmakedefine HAVE_STL_CONTAINER_INCOMPLETE_TYPES | ||
#cmakedefine KDL_USE_NEW_TREE_INTERFACE | ||
|
||
#endif //#define KDL_CONFIG_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.