Comments (6)
Thanks for the report.
Solution: Use linker segments also in MSC.
There is an upstream PR to fix this in ctest
but it doesn't seem to have been merged: bvdberg/ctest#35
I'd prefer not to include local fixes for this issue so I think I will pass on this.
The PR also includes some other fixes: "fix build error in VS: use const char* in struct lxw_header_footer_options". Any idea why this doesn't show up in the "CMake on Windows" CI test?
from libxlsxwriter.
VS build error
The error occurs when compiling the following code in a C++ file, even when xlsxwriter.h uses the extern "C" { ... } declaration.
lxw_header_footer_options header_options;
header_options.image_left = "logo_small.png";
gives error C2440: '=': cannot convert from 'const char [15]' to 'char *'
This works in C, so cmake builds don't complain. However, it should be possible to use the struct members also from a C++ implementation file without writing strange things like
header_options.image_left = const_cast<char*>("logo_small.png");
using const char*
for image_strings[]
in _worksheet_set_header_footer_image
is not really required as this is always C code, but it's cleaner.
ctest
I saw ctest.h was already modified (see its git log) to "work" on Windows. So I wondered that it compiles, but no tests are found.
IMHO, in the short term, working unit tests under Windows are important for libxlsxwriter development. The ctest repository seems to be a bit abandoned, so I doubt if the PR you mentioned will ever be merged into ctest, also because there are lots of guesses and no clear statements how the MS compiler works. (The source of truth is here I think: https://devblogs.microsoft.com/oldnewthing/20181107-00/?p=100155 and the two follow-up articles.)
I mean, if ctest once supports MSVC, you can simply copy the latest version from there and you're done.
from libxlsxwriter.
The error occurs when compiling the following code in a C++ file, even when xlsxwriter.h uses the extern "C" { ... } declaration.
Thanks for flagging this. I'll look into that separately. I have a simple test to ensure CPP compatible const char*
in the APIs but it doesn't flag them in structs or assignments so I'm going to work on that for a bit to see if I can have better automated tests.
After that I'll look at the unit test part of the PR. I just need to figure out if I should upgrade to the latest ctest.h
before adding this fix.
from libxlsxwriter.
I've added a fix to change all the public "char*" members to "const char*". You can try it when you get a chance.
I'll look into the ctest.h
issue next. It is likely that I will upgrade to the latest version. The previous version I used with from 2014 with local fixes over time.
from libxlsxwriter.
I updated ctest.h
to the latest version on the ctest
branch. It works well for Unix-like systems but fails completely on Windows.
I think that rather than fix it I'd prefer to disable the unit test compilation on Windows. As you pointed out the tests didn't work previously so it probably isn't a big loss. The functional tests are more comprehensive anyway.
from libxlsxwriter.
In the end I went with the option of turning off the unit tests for MSVC until ctest.h
supports it. I am going to close this and the PR. Thanks for the input.
from libxlsxwriter.
Related Issues (20)
- Build fail with CMake 3.26.3 while trying to find zlib HOT 1
- Feature Request: Add zig package HOT 1
- Broken logic in FindMINIZIP.cmake HOT 3
- Is there any way to update format without value, or update value without format? HOT 1
- Potential regression 1.1.4 -> 1.1.5: Test fails on big-endian architecture (Debian s390x) HOT 3
- errors when I compile HOT 1
- cmake errors HOT 3
- undefined reference to symbol 'deflate' , when I cross compile HOT 4
- New feature: Add signature file for VBA projects HOT 1
- Ability to insert a link with href HOT 2
- How do I insert a picture as embedded in a cell ? HOT 16
- OSSFuzz integration HOT 6
- Maintenance suggestion: update vendored copy of minizip library
- libxlsxwrite can only write data to tables, but not read data from tables? HOT 2
- Using this lib in for another computer language HOT 2
- Implement the $book->set_custom_color() function from the Perl library in the C library HOT 2
- Linker error when trying to use latest version with macOS project HOT 1
- File creation performance HOT 2
- Linux(CentOS6) Build Error.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from libxlsxwriter.