Darwin compilation errors on samples

asked 2015-05-13 16:17:06 -0700

droid gravatar image

Several errors appear when building the AllJoyn samples on Darwin using the trunk:

  1. services/base/notification/cpp/samples/Test/TestService.cc: String typeString = static_cast<std::ostringstream*>(&(std::ostringstream() << type))->str().c_str();</std::ostringstream*>

Cannot take address error

  1. allseen/services/base/sample_apps/cpp/samples/ServerSample/NotificationTesterImpl.cc: clock_gettime(CLOCK_MONOTONIC, &ts);

OSX does not support CLOCK_MONOTONIC

Are there known workarounds for these?

Thanks, Carl

edit retag flag offensive close merge delete


To the best of my knowledge, C++ samples of base services are not supported on Darwin. You might want to check this at the mailing list: allseen-baseservices@lists.allseenalliance.org

praveenb ( 2015-05-17 02:24:08 -0700 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2015-05-27 16:43:07 -0700

droid gravatar image

updated 2015-05-28 08:50:34 -0700

I was able to build samples on Darwin with the following workarounds:

1. services/base/notification/cpp/samples/Test/TestService.cc:

In send(...), change:

String typeString = static_cast<std::ostringstream*>(&(std::ostringstream() << type))->str().c_str();


std::ostringstream oss;
oss << type;
String typeString = oss.str().c_str();

2. services/base/sample_apps/cpp/samples/ServerSample/NotificationTesterImpl.cc:

Add the following at the top of includes:

#if defined(QCC_OS_DARWIN)
#include <sys/time.h>
#include <mach/mach_time.h>
#include <mach/clock.h>
#include <mach/mach.h>

In GetTimestamp(), replace the QCC_OS_GROUP_POSIX define with:

#if defined (QCC_OS_DARWIN) || defined (QCC_OS_GROUP_POSIX)
    struct timespec ts;
    static uint64_t startingOffset = 0;
#if defined (QCC_OS_DARWIN)
    clock_serv_t cclock;
    mach_timespec_t mts;
    host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &cclock);
    clock_get_time(cclock, &mts);
    mach_port_deallocate(mach_task_self(), cclock);
    ts.tv_sec = mts.tv_sec;
    ts.tv_nsec = mts.tv_nsec;
    clock_gettime(CLOCK_MONOTONIC, &ts);
    if (startingOffset == 0) {
        startingOffset = ts.tv_sec;
    timestamp = ((uint64_t)(ts.tv_sec - startingOffset)) * 1000;
    timestamp += (uint64_t)ts.tv_nsec / 1000000;
edit flag offensive delete publish link more


you might file a bug and submit these fixes so everyone can benefit

ry.jones ( 2015-05-27 16:44:53 -0700 )edit

Filed ASABASE-502: https://jira.allseenalliance.org/browse/ASABASE-502 and submitted patch request.

droid ( 2015-05-29 10:54:45 -0700 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2015-05-13 16:17:06 -0700

Seen: 64 times

Last updated: May 28 '15