Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,12 @@ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})

# Create an object library for the driver (single build)
if(NOT CMAKE_VERSION VERSION_LESS "2.8.8")
cmake_policy(SET CMP0063 NEW)
add_library(cpp-driver OBJECT ${CASS_ALL_SOURCE_FILES})
if(NOT WIN32)
set_property(TARGET cpp-driver PROPERTY COMPILE_FLAGS "${CASS_DRIVER_CXX_FLAGS} -fPIC")
endif()
set_target_properties(cpp-driver PROPERTIES CXX_VISIBILITY_PRESET hidden)

# Build both shared and static libraries
set(CASS_BUILD_SHARED ON)
Expand All @@ -198,6 +200,7 @@ include_directories(${CASS_INCLUDES})
if(CASS_BUILD_SHARED)
if(CMAKE_VERSION VERSION_LESS "2.8.8")
add_library(${PROJECT_LIB_NAME} SHARED ${CASS_ALL_SOURCE_FILES})
set_target_properties(${PROJECT_LIB_NAME} PROPERTIES CXX_VISIBILITY_PRESET hidden)
else()
add_library(${PROJECT_LIB_NAME} SHARED $<TARGET_OBJECTS:cpp-driver>)
endif()
Expand Down
3 changes: 2 additions & 1 deletion src/address.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#define __CASS_ADDRESS_HPP_INCLUDED__

#include "hash.hpp"
#include "macros.hpp"

#include <sparsehash/dense_hash_set>

Expand All @@ -29,7 +30,7 @@

namespace cass {

class Address {
class CASS_IMPL_EXPORT Address {
public:
static const Address EMPTY_KEY;
static const Address DELETED_KEY;
Expand Down
4 changes: 3 additions & 1 deletion src/get_time.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

#include <uv.h>

#include "macros.hpp"

#define NANOSECONDS_PER_MICROSECOND 1000LL
#define NANOSECONDS_PER_MILLISECOND 1000000LL
#define NANOSECONDS_PER_SECOND 1000000000LL
Expand All @@ -27,7 +29,7 @@

namespace cass {

uint64_t get_time_since_epoch_us();
CASS_IMPL_EXPORT uint64_t get_time_since_epoch_us();

inline uint64_t get_time_since_epoch_ms() {
return get_time_since_epoch_us() / MICROSECONDS_PER_MILLISECOND;
Expand Down
16 changes: 16 additions & 0 deletions src/macros.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,20 @@ struct StaticNextPow2 {
enum { value = StaticNextPow2Helper<8 * sizeof(size_t) - 1, N>::value };
};

#if !defined(CASS_STATIC)
# if (defined(WIN32) || defined(_WIN32))
# if defined(CASS_BUILDING)
# define CASS_IMPL_EXPORT __declspec(dllexport)
# else
# define CASS_IMPL_EXPORT __declspec(dllexport)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm pretty sure the #else should be __declspec(dllimport). This is an existing typo. Let me do some research.

# endif
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The if and else bodies are identical. Why have this if for CASS_BUILDING?

Copy link
Contributor Author

@API92 API92 May 10, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code copied from include/cassandra.h. In commit fb4c1a6 the message says that it solves some Windows warnings. But I can rewrite this code with single #define.
Really, CASS_IMPL_EXPORT needed only for exporting some symbols for unit tests. Maybe would it be better to add macro CASS_BUILDING_TESTS and only if it is set, then to define CASS_IMPL_EXPORT?

# elif (defined(__SUNPRO_C) || defined(__SUNPRO_CC)) && !defined(CASS_STATIC)
# define CASS_IMPL_EXPORT __global
# elif (defined(__GNUC__) && __GNUC__ >= 4) || defined(__INTEL_COMPILER)
# define CASS_IMPL_EXPORT __attribute__ ((visibility("default")))
# endif
#else
#define CASS_IMPL_EXPORT
#endif

#endif
2 changes: 1 addition & 1 deletion src/timestamp_generator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class ServerSideTimestampGenerator : public TimestampGenerator {
virtual int64_t next() { return CASS_INT64_MIN; }
};

class MonotonicTimestampGenerator : public TimestampGenerator {
class CASS_IMPL_EXPORT MonotonicTimestampGenerator : public TimestampGenerator {
public:
MonotonicTimestampGenerator(int64_t warning_threshold_us = 1000000,
int64_t warning_interval_ms = 1000)
Expand Down
2 changes: 1 addition & 1 deletion src/utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ inline size_t next_pow_2(size_t num) {

std::string opcode_to_string(int opcode);

void explode(const std::string& str, std::vector<std::string>& vec, const char delimiter = ',');
CASS_IMPL_EXPORT void explode(const std::string& str, std::vector<std::string>& vec, const char delimiter = ',');

std::string& trim(std::string& str);

Expand Down