[DEBUG] windows compilation correction

This commit is contained in:
Edouard DUPIN 2014-09-15 21:07:28 +02:00
parent 3db451068b
commit 311346dce2
7 changed files with 94 additions and 61 deletions

View File

@ -597,6 +597,7 @@ static int32_t getColorSize()
static const int32_t tmpp = sizeof(listOfColor) / sizeof(colorList_ts);
return tmpp;
}
namespace etk {
#include "Color_8_bits.cxx"
#include "Color_16_bits.cxx"
@ -604,3 +605,4 @@ namespace etk {
#include "Color_float.cxx"
#include "Color_double.cxx"
};

View File

@ -352,19 +352,21 @@ namespace etk {
//! @not-in-doc
template<int MY_TYPE_SIZE> std::ostream& operator <<(std::ostream& _os, const Color<uint8_t, MY_TYPE_SIZE>& _obj) { // RGB & RGBA 8 bits
template<int MY_TYPE_SIZE> std::ostream& operator <<(std::ostream& _os, const Color<uint8_t, MY_TYPE_SIZE>& _obj) { // RGB & RGBA 8 bits
std::ostringstream oss;
if (MY_TYPE_SIZE >= 3) {
_os << "#";
_os << (etk::to_string_format<uint32_t, 2>(_obj.r(), std::hex)).c_str();
oss << std::setw(2) << std::setfill('0') << std::hex << _obj.r();
if (MY_TYPE_SIZE >= 2) {
_os << (etk::to_string_format<uint32_t, 2>(_obj.g(), std::hex)).c_str();
oss << std::setw(2) << std::setfill('0') << std::hex << _obj.g();
}
if (MY_TYPE_SIZE >= 3) {
_os << (etk::to_string_format<uint32_t, 2>(_obj.b(), std::hex)).c_str();
oss << std::setw(2) << std::setfill('0') << std::hex << _obj.b();
}
if (MY_TYPE_SIZE >= 4) {
_os << (etk::to_string_format<uint32_t, 2>(_obj.a(), std::hex)).c_str();
oss << std::setw(2) << std::setfill('0') << std::hex << _obj.a();
}
_os << oss.str();
} else {
if (MY_TYPE_SIZE >= 2) {
_os << "be";
@ -372,17 +374,19 @@ namespace etk {
_os << "Mono";
}
_os << "[U8](";
_os << "0x" << (etk::to_string_format<uint32_t, 2>(_obj.r(), std::hex)).c_str();
oss << "0x" << std::setw(2) << std::setfill('0') << std::hex << _obj.r();
if (MY_TYPE_SIZE >= 2) {
_os << ",";
_os << "0x" << (etk::to_string_format<uint32_t, 2>(_obj.g(), std::hex)).c_str();
oss << "0x" << std::setw(2) << std::setfill('0') << std::hex << _obj.g();
}
_os << oss.str();
_os << ")";
}
return _os;
}
//! @not-in-doc
template<int MY_TYPE_SIZE> std::ostream& operator <<(std::ostream& _os, const Color<uint16_t, MY_TYPE_SIZE>& _obj) { // RGB & RGBA 8 bits
template<int MY_TYPE_SIZE> std::ostream& operator <<(std::ostream& _os, const Color<uint16_t, MY_TYPE_SIZE>& _obj) { // RGB & RGBA 8 bits
std::ostringstream oss;
if (MY_TYPE_SIZE >= 4) {
_os << "rgba";
} else if (MY_TYPE_SIZE >= 3) {
@ -393,24 +397,22 @@ namespace etk {
_os << "Mono";
}
_os << "[U16](";
_os << "0x" << (etk::to_string_format<uint32_t, 4>(_obj.r(), std::hex)).c_str();
oss << "0x" << std::setw(4) << std::setfill('0') << std::hex << _obj.r();
if (MY_TYPE_SIZE >= 2) {
_os << ",";
_os << "0x" << (etk::to_string_format<uint32_t, 4>(_obj.g(), std::hex)).c_str();
oss << ",0x" << std::setw(4) << std::setfill('0') << std::hex << _obj.g();
}
if (MY_TYPE_SIZE >= 3) {
_os << ",";
_os << "0x" << (etk::to_string_format<uint32_t, 4>(_obj.b(), std::hex)).c_str();
oss << ",0x" << std::setw(4) << std::setfill('0') << std::hex << _obj.b();
}
if (MY_TYPE_SIZE >= 4) {
_os << ",";
_os << "0x" << (etk::to_string_format<uint32_t, 4>(_obj.a(), std::hex)).c_str();
oss << ",0x" << std::setw(4) << std::setfill('0') << std::hex << _obj.a();
}
_os << ")";
_os << oss.str() << ")";
return _os;
}
//! @not-in-doc
template<int MY_TYPE_SIZE> std::ostream& operator <<(std::ostream& _os, const Color<uint32_t, MY_TYPE_SIZE>& _obj) { // RGB & RGBA 8 bits
template<int MY_TYPE_SIZE> std::ostream& operator <<(std::ostream& _os, const Color<uint32_t, MY_TYPE_SIZE>& _obj) { // RGB & RGBA 8 bits
std::ostringstream oss;
if (MY_TYPE_SIZE >= 4) {
_os << "rgba";
} else if (MY_TYPE_SIZE >= 3) {
@ -421,20 +423,17 @@ namespace etk {
_os << "Mono";
}
_os << "[U32](";
_os << "0x" << (etk::to_string_format<uint32_t, 8>(_obj.r(), std::hex)).c_str();
oss << "0x" << std::setw(8) << std::setfill('0') << std::hex << _obj.r();
if (MY_TYPE_SIZE >= 2) {
_os << ",";
_os << "0x" << (etk::to_string_format<uint32_t, 8>(_obj.g(), std::hex)).c_str();
oss << ",0x" << std::setw(8) << std::setfill('0') << std::hex << _obj.g();
}
if (MY_TYPE_SIZE >= 3) {
_os << ",";
_os << "0x" << (etk::to_string_format<uint32_t, 8>(_obj.b(), std::hex)).c_str();
oss << ",0x" << std::setw(8) << std::setfill('0') << std::hex << _obj.b();
}
if (MY_TYPE_SIZE >= 4) {
_os << ",";
_os << "0x" << (etk::to_string_format<uint32_t, 8>(_obj.a(), std::hex)).c_str();
oss << ",0x" << std::setw(8) << std::setfill('0') << std::hex << _obj.a();
}
_os << ")";
_os << oss.str() << ")";
return _os;
}
//! @not-in-doc

View File

@ -14,7 +14,9 @@
#include <etk/tool.h>
#include <map>
#ifdef __TARGET_OS__Windows
#include "windows.h"
#include <tchar.h>
#include <iostream>
#include <windows.h>
#endif
extern "C" {
// file browsing ...
@ -210,7 +212,7 @@ std::string getApplicationPath() {
char binaryCompleatePath[FILENAME_MAX];
memset(binaryCompleatePath, 0, FILENAME_MAX);
#ifdef __TARGET_OS__Windows
getModuleFileName(NULL, binaryCompleatePath, FILENAME_MAX);
GetModuleFileName(NULL, binaryCompleatePath, FILENAME_MAX);
if (0==strlen(binaryCompleatePath)) {
TK_CRITICAL("Can not get the binary position in the tree ==> this is really bad ...");
} else {
@ -570,8 +572,8 @@ void etk::FSNode::privateSetName(const std::string& _newName) {
char tmpValMaj[10];
sprintf(tmpVal, "%c:/", iii);
sprintf(tmpValMaj, "%c:/", iii+'A'-'a');
if( true == destFilename.startWith(tmpVal)
|| true == destFilename.startWith(tmpValMaj)) {
if( etk::start_with(destFilename, tmpVal) == true
|| etk::start_with(destFilename, tmpValMaj) == true) {
isRootFolder = true;
break;
}

View File

@ -11,7 +11,7 @@
etk::Semaphore::Semaphore(uint32_t _nbBasicElement, uint32_t _nbMessageMax) {
// create interface mutex :
m_semaphore = createSemaphore(NULL, _nbBasicElement, _nbMessageMax, NULL);
m_semaphore = CreateSemaphore(NULL, _nbBasicElement, _nbMessageMax, NULL);
TK_ASSERT(m_semaphore != 0, "Error creating SEMAPHORE ...");
}
@ -22,22 +22,22 @@ etk::Semaphore::~Semaphore() {
uint32_t etk::Semaphore::getCount() {
LONG tmpData = 0;
releaseSemaphore(m_semaphore, 0, &tmpData);
ReleaseSemaphore(m_semaphore, 0, &tmpData);
return tmpData;
}
void etk::Semaphore::post() {
releaseSemaphore(m_semaphore, 1, NULL);
ReleaseSemaphore(m_semaphore, 1, NULL);
}
void etk::Semaphore::wait() {
waitForSingleObject(m_semaphore, INFINITE);
WaitForSingleObject(m_semaphore, INFINITE);
}
bool etk::Semaphore::wait(uint64_t _timeOutInUs) {
DWORD result = waitForSingleObject(m_semaphore, _timeOutInUs);
DWORD result = WaitForSingleObject(m_semaphore, _timeOutInUs);
if (result == WAIT_FAILED) {
TK_ERROR("Failed to wait for semaphore ");
return false;

View File

@ -274,7 +274,7 @@ namespace etk {
}
template<> std::string to_string<int64_t>(const int64_t& _val) {
char tmpVal[256];
#if (defined(__TARGET_OS__Android))
#if (defined(__TARGET_OS__Android) || defined(__TARGET_OS__Windows))
sprintf(tmpVal, "%lld", _val);
#else
sprintf(tmpVal, "%ld", _val);
@ -298,7 +298,7 @@ namespace etk {
}
template<> std::string to_string<uint64_t>(const uint64_t& _val) {
char tmpVal[256];
#if (defined(__TARGET_OS__Android))
#if (defined(__TARGET_OS__Android) || defined(__TARGET_OS__Windows))
sprintf(tmpVal, "%llu", _val);
#else
sprintf(tmpVal, "%lu", _val);
@ -835,7 +835,7 @@ int32_t etk::string_to_int32_t(const std::string& _str, int _base) {
}
int64_t etk::string_to_int64_t(const std::string& _str, int _base) {
int64_t ret = 0;
#if (defined(__TARGET_OS__Android))
#if (defined(__TARGET_OS__Android) || defined(__TARGET_OS__Windows))
sscanf(_str.c_str(), "%lld", &ret);
#else
sscanf(_str.c_str(), "%ld", &ret);
@ -859,7 +859,7 @@ uint32_t etk::string_to_uint32_t(const std::string& _str, int _base) {
}
uint64_t etk::string_to_uint64_t(const std::string& _str, int _base) {
uint64_t ret = 0;
#if (defined(__TARGET_OS__Android))
#if (defined(__TARGET_OS__Android) || defined(__TARGET_OS__Windows))
sscanf(_str.c_str(), "%llu", &ret);
#else
sscanf(_str.c_str(), "%lu", &ret);

View File

@ -61,7 +61,7 @@ namespace utf8 {
};
namespace std {
#ifdef __TARGET_OS__MacOs
#if (defined(__TARGET_OS__MacOs) || defined(__TARGET_OS__Windows))
typedef std::basic_string<char32_t> u32string;
#endif
#if (defined(__TARGET_OS__Android))
@ -102,26 +102,6 @@ namespace etk {
template <class TYPE> bool from_string(TYPE& _variableRet, const std::string& _value);
template <class TYPE> bool from_string(TYPE& _variableRet, const std::u32string& _value);
template<class TYPE, int size=0> std::string to_string_format(TYPE t, std::ios_base & (*f)(std::ios_base&)) {
std::ostringstream oss;
if (size==0) {
oss << f << t;
} else {
oss << std::setw(size) << std::setfill('0') << f << t;
}
return oss.str();
}
template<class TYPE, int size=0> std::u32string to_u32string_format(TYPE t, std::ios_base & (*f)(std::ios_base&)) {
std::ostringstream oss;
if (size==0) {
oss << f << t;
} else {
oss << std::setw(size) << std::setfill('0') << f << t;
}
return etk::to_u32string(oss.str());
}
long double string_to_long_double(const std::string& _str);
long double string_to_long_double(const std::u32string& _str);
@ -209,5 +189,9 @@ namespace std {
int32_t strlen(const char32_t * _data);
#if (defined(__TARGET_OS__Windows))
#define M_PI 3.14159265358979323846
#endif
#endif

View File

@ -40,7 +40,53 @@
#define UINT64_MAX (__UINT64_C(18446744073709551615))
#endif
#endif
#include <etk/stdTools.h>
typedef float float_t;
/*
Target ARCH values (CPU core TYPE):
__TARGET_ARCH__ARM
__TARGET_ARCH__POWER_PC
__TARGET_ARCH__INTEL
__TARGET_ARCH__AMD
__TARGET_ARCH__MICROCHIP
...
Target ARCH_VERSION values:
__TARGET_ARCH_VERSION__05_00 // for exemple arm v5 (very small ==> simple core...)
__TARGET_ARCH_VERSION__07_00 // for exemple arm v7 (with NEON)
Target ADDR values (adressing mode):
__TARGET_ADDR__16BITS
__TARGET_ADDR__32BITS
__TARGET_ADDR__64BITS
__TARGET_ADDR__128BITS
Target CORE values (adressing mode):
__TARGET_CORE__1 // 1 core
__TARGET_CORE__2 // 2 core
__TARGET_CORE__3 // 3 core
__TARGET_CORE__4 // 4 core
__TARGET_CORE__X // x core ==> must auto update
..
*/
// Check windows
#ifdef _WIN32
#define __TARGET_ARCH__32BITS
#endif
#ifdef _WIN64
#define __TARGET_ARCH__64BITS
#endif
// Check GCC
#if __GNUC__
#if __x86_64__ || __ppc64__
#define __TARGET_ARCH__64BITS
#else
#define __TARGET_ARCH__32BITS
#endif
#endif
#include <etk/stdTools.h>
#ifndef _WIN32
typedef float float_t;
#endif
#endif