mirror of
https://github.com/jmcnamara/libxlsxwriter.git
synced 2026-05-15 14:15:54 -06:00
[GH-ISSUE #368] Problem compiling images.c example in Visual Studio C++ #293
Labels
No labels
awaiting user feedback
bug
cmake
cmake
docs
feature request
in progress
long term
medium term
medium term
pull-request
question
question
ready to close
short term
under investigation
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: github-starred/libxlsxwriter#293
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @algaspar on GitHub (Apr 10, 2022).
Original GitHub issue: https://github.com/jmcnamara/libxlsxwriter/issues/368
I have been using libxlsxwriter successfully in some C++ applications using Visual Studio 2017 with version 1.1.4 from vcpkg.io. Recently I had occasion to try inserting an image. Just inserting an image with
works fine. I wanted to scale my image down slightly, but if I tried any options, I had a problem. I was using this code:
Thinking I might have been using lxw_image_options and worksheet_insert_image_opt() incorrectly, I grabbed the images.c example from the documentation and tried compiling it in a new project. When I do a build, I get the same compiler errors I got in my code (here's the first batch of errors I got from images.c generated from the first use of lxw_image_options and worksheet_insert_image_opt()). It really doesn't like '.x_scale' and '.y_scale':
This repeats for every instance of lxw_image_options and subsequent call to worksheet_insert_image_opt() in images.c.
Am I doing something wrong or do the image options just not work for C++?
Thanks for any help or suggestions (and thanks for a great library!)--
Al
@jmcnamara commented on GitHub (Apr 10, 2022):
This is a C vs C++ difference and not a libxlsxwriter issue.
C style field initializers aren't supported in C++. See the various answers and explanations here: https://stackoverflow.com/questions/11516657/c-structure-initialization
Instead you should use C++ compatible initializers, something like this:
@algaspar commented on GitHub (Apr 10, 2022):
Thank you very much for your quick and detailed reply. I understand what I
need to do.
Best--
Al Gaspar
On Sun, Apr 10, 2022, 4:19 AM John McNamara @.***>
wrote: