Skip to content

Commit 4089a0c

Browse files
committed
Merge pull request #14 from ros2/fix_error_string
fix rmw error strings
2 parents e197393 + 39cf881 commit 4089a0c

File tree

3 files changed

+46
-15
lines changed

3 files changed

+46
-15
lines changed

rmw/CMakeLists.txt

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
cmake_minimum_required(VERSION 2.8.3)
22

3-
project(rmw NONE)
3+
project(rmw C)
44

55
find_package(ament_cmake REQUIRED)
66

7+
include_directories(include)
8+
add_library(${PROJECT_NAME} SHARED "src/error_handling.c")
9+
710
ament_export_dependencies(rosidl_generator_c)
811
ament_export_include_directories(include)
12+
ament_export_libraries(${PROJECT_NAME})
913

1014
if(AMENT_ENABLE_TESTING)
1115
find_package(ament_lint_auto REQUIRED)
@@ -22,3 +26,9 @@ install(
2226
DIRECTORY include/
2327
DESTINATION include
2428
)
29+
install(
30+
TARGETS ${PROJECT_NAME}
31+
ARCHIVE DESTINATION lib
32+
LIBRARY DESTINATION lib
33+
RUNTIME DESTINATION bin
34+
)

rmw/include/rmw/error_handling.h

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,26 +20,16 @@ extern "C"
2020
{
2121
#endif
2222

23-
#include <string.h>
24-
2523
#include "macros.h"
2624
#include "visibility_control.h"
2725

28-
RMW_THREAD_LOCAL char * __rmw_error_string = 0;
29-
30-
RMW_LOCAL
26+
RMW_PUBLIC
3127
void
32-
rmw_set_error_string(const char * error_string)
33-
{
34-
__rmw_error_string = strdup(error_string);
35-
}
28+
rmw_set_error_string(const char * error_string);
3629

37-
RMW_LOCAL
30+
RMW_PUBLIC
3831
const char *
39-
rmw_get_error_string()
40-
{
41-
return __rmw_error_string;
42-
}
32+
rmw_get_error_string();
4333

4434
#if __cplusplus
4535
}

rmw/src/error_handling.c

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Copyright 2015 Open Source Robotics Foundation, Inc.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
#include <string.h>
16+
17+
#include <rmw/error_handling.h>
18+
19+
RMW_THREAD_LOCAL char * __rmw_error_string = 0;
20+
21+
void
22+
rmw_set_error_string(const char * error_string)
23+
{
24+
__rmw_error_string = strdup(error_string);
25+
}
26+
27+
const char *
28+
rmw_get_error_string()
29+
{
30+
return __rmw_error_string;
31+
}

0 commit comments

Comments
 (0)