Skip to content

Commit

Permalink
add mingw support (#468)
Browse files Browse the repository at this point in the history
Signed-off-by: U-CW01\uig08771 <uig08771@HIL4255W.cw01.contiwan.com>
(cherry picked from commit 826cd46)
  • Loading branch information
felixf4xu authored Jun 5, 2024
1 parent 8f5d6bc commit b2ad5ed
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions include/rcutils/macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ extern "C"
{
#endif

#ifndef _WIN32
#ifndef _MSC_VER
/// A macro to make the compiler warn when the return value of a function is not used.
#define RCUTILS_WARN_UNUSED __attribute__((warn_unused_result))
#else
/// A macro to make the compiler warn when the return value of a function is not used.
/// A macro to make the compiler (MSVC) warn when the return value of a function is not used.
#define RCUTILS_WARN_UNUSED _Check_return_
#endif

Expand Down
2 changes: 1 addition & 1 deletion include/rcutils/stdatomic_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
# endif
#endif

#if !defined(_WIN32)
#if !defined(_WIN32) || defined(__MINGW64__)

// The my__has_feature avoids a preprocessor error when you check for it and
// use it on the same line below.
Expand Down
4 changes: 2 additions & 2 deletions src/process.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ char * rcutils_get_executable_name(rcutils_allocator_t allocator)

#if defined __APPLE__ || defined __FreeBSD__ || (defined __ANDROID__ && __ANDROID_API__ >= 21)
const char * appname = getprogname();
#elif defined __GNUC__ && !defined(__QNXNTO__) && !defined(__OHOS__)
#elif (defined __GNUC__ && !defined(__MINGW64__)) && !defined(__QNXNTO__) && !defined(__OHOS__)
const char * appname = program_invocation_name;
#elif defined _WIN32 || defined __CYGWIN__
char appname[MAX_PATH];
Expand All @@ -85,7 +85,7 @@ char * rcutils_get_executable_name(rcutils_allocator_t allocator)
}

// Get just the executable name (Unix may return the absolute path)
#if defined __APPLE__ || defined __FreeBSD__ || defined __GNUC__
#if defined __APPLE__ || defined __FreeBSD__ || (defined __GNUC__ && !defined(__MINGW64__))
// We need an intermediate copy because basename may modify its arguments
char * intermediate = rcutils_strdup(appname, allocator);
if (NULL == intermediate) {
Expand Down
2 changes: 1 addition & 1 deletion test/test_process.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ TEST(TestProcess, test_get_executable_name) {
EXPECT_STREQ(NULL, rcutils_get_executable_name(time_bomb_allocator));

// Allocating intermediate fails. This allocation doesn't happen on windows
#if defined __APPLE__ || defined __FreeBSD__ || defined __GNUC__
#if defined __APPLE__ || defined __FreeBSD__ || (defined __GNUC__ && !defined(__MINGW64__))
set_time_bomb_allocator_malloc_count(time_bomb_allocator, 1);
EXPECT_STREQ(NULL, rcutils_get_executable_name(time_bomb_allocator));
#endif
Expand Down

0 comments on commit b2ad5ed

Please sign in to comment.