commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] [gnuradio] 02/03: gr-audio OSX: fix casting of Int32 t


From: git
Subject: [Commit-gnuradio] [gnuradio] 02/03: gr-audio OSX: fix casting of Int32 to char[] to a memcpy to make older GCC happy.
Date: Fri, 27 Jun 2014 13:30:44 +0000 (UTC)

This is an automated email from the git hooks/post-receive script.

trondeau pushed a commit to branch maint
in repository gnuradio.

commit 369839f6feb596e372c8047e8282f91a07a89fa3
Author: Michael Dickens <address@hidden>
Date:   Thu Jun 26 19:36:13 2014 -0400

    gr-audio OSX: fix casting of Int32 to char[] to a memcpy to make older GCC 
happy.
---
 gr-audio/lib/osx/osx_common.h | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/gr-audio/lib/osx/osx_common.h b/gr-audio/lib/osx/osx_common.h
index 34266f2..59b866d 100644
--- a/gr-audio/lib/osx/osx_common.h
+++ b/gr-audio/lib/osx/osx_common.h
@@ -35,9 +35,9 @@ namespace osx {
 #define check_error_and_throw(err,what,throw_str)                      \
   if(err) {                                                             \
     OSStatus error = static_cast<OSStatus>(err);                        \
-    char err_str[5];                                                    \
-    *((UInt32*)err_str) = error;                                       \
-    err_str[4] = 0;                                                    \
+    char err_str[sizeof(OSStatus)+1];                                  \
+    memcpy((void*)(&err_str), (void*)(&error), sizeof(OSStatus));      \
+    err_str[sizeof(OSStatus)] = 0;                                     \
     GR_LOG_FATAL(d_logger, boost::format(what));                       \
     GR_LOG_FATAL(d_logger, boost::format("  Error# %u ('%s')")         \
                 % error % err_str);                                    \
@@ -49,9 +49,9 @@ namespace osx {
 #define check_error(err,what)                                           \
   if(err) {                                                             \
     OSStatus error = static_cast<OSStatus>(err);                        \
-    char err_str[5];                                                    \
-    *((UInt32*)err_str) = error;                                       \
-    err_str[4] = 0;                                                    \
+    char err_str[sizeof(OSStatus)+1];                                  \
+    memcpy((void*)(&err_str), (void*)(&error), sizeof(OSStatus));      \
+    err_str[sizeof(OSStatus)] = 0;                                     \
     GR_LOG_WARN(d_logger, boost::format(what));                                
\
     GR_LOG_WARN(d_logger, boost::format("  Error# %u ('%s')")          \
                   % error % err_str);                                  \



reply via email to

[Prev in Thread] Current Thread [Next in Thread]