Skip to content

Commit

Permalink
Convert public char* to const char* for C++ compatibility.
Browse files Browse the repository at this point in the history
  • Loading branch information
jmcnamara committed Sep 24, 2023
1 parent e94bbb5 commit 7bc9c0b
Show file tree
Hide file tree
Showing 45 changed files with 204 additions and 162 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/cmake_actions.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build with CMake
name: Test CMake build

on: [push, pull_request]

Expand All @@ -7,6 +7,7 @@ jobs:
name:
Cmake
strategy:
fail-fast: false
matrix:
cc: [gcc, clang]
cmake_flags: ["",
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/make_actions.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build with Make
name: Test Make build

on: [push, pull_request]

Expand All @@ -7,6 +7,7 @@ jobs:
name:
Make
strategy:
fail-fast: false
matrix:
cc: [gcc, clang]
make_flags: ["",
Expand Down
32 changes: 32 additions & 0 deletions .github/workflows/make_cpp.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Test CPP build

on: [push, pull_request]

jobs:
build:
name:
Make
strategy:
fail-fast: false
matrix:
cc: [gcc, clang]

runs-on: ubuntu-latest
env:
CC: ${{ matrix.cc }}
CXX: ${{ matrix.cxx }}
CFLAGS: '-Werror -Wno-deprecated'

steps:
- uses: actions/checkout@v2

- name: Install dependencies
run: |
sudo apt update
sudo apt-get -y install zlib1g-dev
- name: make
run: |
make V=1
make examples_cpp V=1 CC=${{ matrix.cxx }}
2 changes: 1 addition & 1 deletion .github/workflows/windows_build.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Cmake on Windows
name: Test Cmake build on Windows

on: [push, pull_request]

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/zig_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ jobs:
- uses: goto-bus-stop/setup-zig@v2
with:
version: master

- name: Build Summary
run: zig build -DBUILD_TESTS -DBUILD_EXAMPLES -DUSE_SYSTEM_MINIZIP --summary all -freference-trace
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ universal_binary :
examples : all
$(Q)$(MAKE) -C examples

# Build the example programs with CPP for compatibility checking.
examples_cpp : all
$(Q)$(MAKE) -C examples CC=$(CXX)

# Clean src and test directories.
clean :
$(Q)$(MAKE) clean -C src
Expand Down
2 changes: 1 addition & 1 deletion examples/autofilter.c
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ int main() {
worksheet_autofilter(worksheet5, 0, 0, 50, 3);

/* Add the filter criteria. */
char* list[] = {"East", "North", "South", NULL};
const char* list[] = {"East", "North", "South", NULL};

worksheet_filter_list(worksheet5, 0, list);

Expand Down
2 changes: 1 addition & 1 deletion examples/chart_data_labels.c
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ int main() {
* font for the custom items as an extra example.
*/
lxw_chart_data_label data_label7_1 = {.value = "=Sheet1!$C$2", .font = &font2};
lxw_chart_data_label data_label7_2 = {0};
lxw_chart_data_label data_label7_2 = {};
lxw_chart_data_label data_label7_3 = {.value = "=Sheet1!$C$4", .font = &font2};
lxw_chart_data_label data_label7_4 = {.value = "=Sheet1!$C$5", .font = &font2};

Expand Down
2 changes: 1 addition & 1 deletion examples/chart_styles.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
int main() {

int chart_types[] = {LXW_CHART_COLUMN, LXW_CHART_AREA, LXW_CHART_LINE, LXW_CHART_PIE};
char *chart_names[] = {"Column", "Area", "Line", "Pie"};
const char *chart_names[] = {"Column", "Area", "Line", "Pie"};
char chart_title[32] = {0};
int row_num, col_num, chart_num, style_num;
lxw_worksheet *worksheet;
Expand Down
3 changes: 2 additions & 1 deletion examples/conditional_format1.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ int main() {
format_set_font_color(custom_format, LXW_COLOR_RED);

/* Create a conditional format object. A static object would also work. */
lxw_conditional_format *conditional_format = calloc(1, sizeof(lxw_conditional_format));
lxw_conditional_format *conditional_format =
(lxw_conditional_format *)calloc(1, sizeof(lxw_conditional_format));

/* Set the format type: a cell conditional: */
conditional_format->type = LXW_CONDITIONAL_TYPE_CELL;
Expand Down
3 changes: 2 additions & 1 deletion examples/conditional_format2.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ int main() {
format_set_font_color(format2, 0x006100);

/* Create a single conditional format object to reuse in the examples. */
lxw_conditional_format *conditional_format = calloc(1, sizeof(lxw_conditional_format));
lxw_conditional_format *conditional_format =
(lxw_conditional_format *)calloc(1, sizeof(lxw_conditional_format));

/*
* Example 1. Conditional formatting based on simple cell based criteria.
Expand Down
5 changes: 3 additions & 2 deletions examples/data_validate.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ int main() {

lxw_workbook *workbook = workbook_new("data_validate1.xlsx");
lxw_worksheet *worksheet = workbook_add_worksheet(workbook, NULL);
lxw_data_validation *data_validation = calloc(1, sizeof(lxw_data_validation));
lxw_data_validation *data_validation =
(lxw_data_validation *)calloc(1, sizeof(lxw_data_validation));

/* Add a format to use to highlight the header cells. */
lxw_format *format = workbook_add_format(workbook);
Expand Down Expand Up @@ -154,7 +155,7 @@ int main() {
"Select a value from a drop down list",
NULL);

char *list[] = {"open", "high", "close", NULL};
const char *list[] = {"open", "high", "close", NULL};

data_validation->validate = LXW_VALIDATION_TYPE_LIST;
data_validation->value_list = list;
Expand Down
2 changes: 1 addition & 1 deletion examples/dates_and_times04.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ int main() {
/* Examples date and time formats. In the output file compare how changing
* the format strings changes the appearance of the date.
*/
char *date_formats[] = {
const char *date_formats[] = {
"dd/mm/yy",
"mm/dd/yy",
"dd m yy",
Expand Down
2 changes: 1 addition & 1 deletion examples/format_num_format.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ int main() {
/* Format a Zip code. */
format_set_num_format(format11, "00000");
worksheet_write_number(worksheet, 13, 0, 1209, format11);

/* Close the workbook, save the file and free any memory. */
return workbook_close(workbook);
}
4 changes: 2 additions & 2 deletions examples/output_buffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include "xlsxwriter.h"

int main() {
char *output_buffer;
const char *output_buffer;
size_t output_buffer_size;

/* Set the worksheet options. */
Expand All @@ -36,7 +36,7 @@ int main() {
FILE *file = fopen("output_buffer.xlsx", "wb");
fwrite(output_buffer, output_buffer_size, 1, file);
fclose(file);
free(output_buffer);
free((void *)output_buffer);

return ferror(stdout);
}
4 changes: 2 additions & 2 deletions include/xlsxwriter/chart.h
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,7 @@ typedef struct lxw_chart_pattern {
typedef struct lxw_chart_font {

/** The chart font name, such as "Arial" or "Calibri". */
char *name;
const char *name;

/** The chart font size. The default is 11. */
double size;
Expand Down Expand Up @@ -800,7 +800,7 @@ typedef struct lxw_chart_data_label {

/** The string or formula value for the data label. See
* @ref chart_custom_labels. */
char *value;
const char *value;

/** Option to hide/delete the data label from the chart series.
* See @ref chart_custom_labels. */
Expand Down
6 changes: 3 additions & 3 deletions include/xlsxwriter/chartsheet.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ typedef struct lxw_chartsheet {
struct lxw_protection_obj protection;
uint8_t is_protected;

char *name;
char *quoted_name;
char *tmpdir;
const char *name;
const char *quoted_name;
const char *tmpdir;
uint16_t index;
uint8_t active;
uint8_t selected;
Expand Down
8 changes: 4 additions & 4 deletions include/xlsxwriter/packager.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ typedef struct lxw_packager {
size_t output_buffer_size;
zipFile zipfile;
zip_fileinfo zipfile_info;
char *filename;
char *buffer;
const char *filename;
const char *buffer;
char *output_buffer;
char *tmpdir;
const char *tmpdir;
uint8_t use_zip64;

} lxw_packager;
Expand All @@ -82,7 +82,7 @@ extern "C" {
#endif
/* *INDENT-ON* */

lxw_packager *lxw_packager_new(const char *filename, char *tmpdir,
lxw_packager *lxw_packager_new(const char *filename, const char *tmpdir,
uint8_t use_zip64);
void lxw_packager_free(lxw_packager *packager);
lxw_error lxw_create_package(lxw_packager *self);
Expand Down
2 changes: 1 addition & 1 deletion include/xlsxwriter/styles.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ extern "C" {
lxw_styles *lxw_styles_new(void);
void lxw_styles_free(lxw_styles *styles);
void lxw_styles_assemble_xml_file(lxw_styles *self);
void lxw_styles_write_string_fragment(lxw_styles *self, char *string);
void lxw_styles_write_string_fragment(lxw_styles *self, const char *string);
void lxw_styles_write_rich_font(lxw_styles *styles, lxw_format *format);

/* Declarations required for unit testing. */
Expand Down
4 changes: 2 additions & 2 deletions include/xlsxwriter/utility.h
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,8 @@ void lxw_str_tolower(char *str);
#define lxw_strcasecmp strcasecmp
#endif

FILE *lxw_tmpfile(char *tmpdir);
FILE *lxw_get_filehandle(char **buf, size_t *size, char *tmpdir);
FILE *lxw_tmpfile(const char *tmpdir);
FILE *lxw_get_filehandle(char **buf, size_t *size, const char *tmpdir);
FILE *lxw_fopen(const char *filename, const char *mode);

/* Use the third party dtoa function to avoid locale issues with sprintf
Expand Down
24 changes: 12 additions & 12 deletions include/xlsxwriter/workbook.h
Original file line number Diff line number Diff line change
Expand Up @@ -182,34 +182,34 @@ typedef struct lxw_defined_name {
*/
typedef struct lxw_doc_properties {
/** The title of the Excel Document. */
char *title;
const char *title;

/** The subject of the Excel Document. */
char *subject;
const char *subject;

/** The author of the Excel Document. */
char *author;
const char *author;

/** The manager field of the Excel Document. */
char *manager;
const char *manager;

/** The company field of the Excel Document. */
char *company;
const char *company;

/** The category of the Excel Document. */
char *category;
const char *category;

/** The keywords of the Excel Document. */
char *keywords;
const char *keywords;

/** The comment field of the Excel Document. */
char *comments;
const char *comments;

/** The status of the Excel Document. */
char *status;
const char *status;

/** The hyperlink base URL of the Excel Document. */
char *hyperlink_base;
const char *hyperlink_base;

/** The file creation date/time shown in Excel. This defaults to the
* current time and date if set to 0. If you wish to create files that are
Expand Down Expand Up @@ -270,13 +270,13 @@ typedef struct lxw_workbook_options {
uint8_t constant_memory;

/** Directory to use for the temporary files created by libxlsxwriter. */
char *tmpdir;
const char *tmpdir;

/** Allow ZIP64 extensions when creating the xlsx file zip container. */
uint8_t use_zip64;

/** Output buffer to use instead of writing to a file */
char **output_buffer;
const char **output_buffer;

/** Used with output_buffer to get the size of the created buffer */
size_t *output_buffer_size;
Expand Down
Loading

0 comments on commit 7bc9c0b

Please sign in to comment.