Closed algaspar closed 2 years ago
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:
lxw_image_options options2 = {0};
options2.x_scale = 0.75;
options2.y_scale = 0.75;
// or
lxw_image_options options2 = {0, 0, 0.75, 0.75, 0, NULL, 0, NULL, NULL};
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:
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:
lxw_image_options options2 = {0}; options2.x_scale = 0.75; options2.y_scale = 0.75; // or lxw_image_options options2 = {0, 0, 0.75, 0.75, 0, NULL, 0, NULL, NULL};
— Reply to this email directly, view it on GitHub https://github.com/jmcnamara/libxlsxwriter/issues/368#issuecomment-1094227228, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALF36ENTCQSL77WVHTRX3YTVEKMLZANCNFSM5TAI3UOA . You are receiving this because you authored the thread.Message ID: @.***>
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