Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Windows build support #26

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pipe -Wall -Wextra -Wfatal-errors -Wformat-security -Wuninitialized -Wfloat-equal -fPIC -g")
if(CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pipe -Wall -Wextra -Wfatal-errors -Wformat-security -Wuninitialized -Wfloat-equal -fPIC -g")
endif(CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS_RELEASE "-O2")

macro(get_variable VAR_NAME VAR_TEXT DEFAULT_VALUE IS_OPTION)
Expand Down
3 changes: 3 additions & 0 deletions include/elasticlient/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
#include <initializer_list>
#include <type_traits>

#ifndef __GNUC__
#undef DELETE
#endif

// Forward cpr::Response existence.
namespace cpr {
Expand Down
3 changes: 3 additions & 0 deletions include/elasticlient/logging.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
#pragma once
#include <string>

#ifndef __GNUC__
#undef ERROR
#endif

/// The elasticlient namespace
namespace elasticlient {
Expand Down
3 changes: 3 additions & 0 deletions src/client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
#include <cpr/cpr.h>
#include "logging-impl.h"

#ifndef __GNUC__
#undef DELETE
#endif

namespace {

Expand Down
20 changes: 16 additions & 4 deletions src/logging-impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,22 @@
#include <cstdio>
#include <cstdarg>


#define LOG(logLevel, args...) \
#ifdef __GNUC__
#define LOG(logLevel, args ...) \
do { \
if(elasticlient::isLoggingEnabled()) { \
elasticlient::propagateLogMessage(logLevel, args); \
} \
} while (false)
#else
#define LOG(logLevel, ...) \
do { \
if(elasticlient::isLoggingEnabled()) { \
elasticlient::propagateLogMessage(logLevel, __VA_ARGS__); \
} \
} while (false)
#endif



namespace elasticlient {
Expand All @@ -33,8 +42,11 @@ void dbgLog(LogLevel logLevel, const std::string &message);


inline void propagateLogMessage(
LogLevel logLevel, const char* message, ...) __attribute__ ((format (printf, 2, 3)));

LogLevel logLevel, const char* message, ...)
#ifdef __GNUC__
__attribute__ ((format (printf, 2, 3)))
#endif
;

void propagateLogMessage(LogLevel logLevel, const char* message, ...) {
va_list args;
Expand Down
3 changes: 3 additions & 0 deletions src/scroll.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
#include <cpr/cpr.h>
#include "logging-impl.h"

#ifndef __GNUC__
#undef DELETE
#endif

namespace elasticlient {

Expand Down