I am trying to use the library simplexlsxwriter with Qt, however when i try to compile I met the following error on several place in the code :
"cannot convert 'const TCHAR* {aka const wchar_t*}' to 'const char*' for argument '1' to 'size_t strlen(const char*)'"
The line in question is:
bool HasZipSuffix(const TCHAR *fn) {
const TCHAR *ext = fn+_tcslen(fn);
}
In order to remove the error i tried the following:
bool HasZipSuffix(const TCHAR *fn) {
const char* fn_cc = reinterpret_cast<const char*> (fn);
const TCHAR *ext = fn+_tcslen(fn_cc );
}
It works, however it introduces a lot of errors (about 3720 issues) during compilations. I use mingw53_32 under Qt.
It is very strange since when i create a simple Makefile as follow:
ROOT_DIR := ./
CXXFLAGS=-MMD -MP -Wall
CXXFLAGS+= -I$(ROOT_DIR)
src = Zip/zip.cpp \
Xlsx/Chartsheet.cpp \
Xlsx/Workbook.cpp \
Xlsx/Worksheet.cpp \
Xlsx/XlsxHeaders.cpp \
main.cpp
includes = Zip/zip.h \
tchar.h \
Xlsx/Chartsheet.h \
Xlsx/SimpleXlsxDef.h \
Xlsx/Workbook.h \
Xlsx/Worksheet.h \
Xlsx/XlsxHeaders.h
object=$(src:.cpp=.o)
%: %.o
$(LINK.cpp) -o $@ $^ $(LDFLAGS)
main: $(object)
-include $(src:.cpp=.d)
The compilation encountered absolutely no difficulty and I obtain the desired binary. So my question is, why using Qt the conversion from const wchar_t* to const char* throw an error while using "raw" mingw compiler, it does not throw any error ?
const wchar_t*
toconst char*
does not throw any error using mingw32 (with gcc version 5.3) but it throw an error when I use the same very same compiler using Qt ? – Schneider Loïc