[PR #273] [CLOSED] Use macro for printing to stderr #455

Closed
opened 2026-05-05 12:16:23 -06:00 by gitea-mirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/jmcnamara/libxlsxwriter/pull/273
Author: @jeroen
Created: 2/16/2020
Status: Closed

Base: masterHead: printerr


📝 Commits (1)

  • 055643d Use single macro for printing to stderr

📊 Changes

3 files changed (+22 additions, -19 deletions)

View changed files

📝 include/xlsxwriter/common.h (+13 -10)
📝 src/Makefile (+1 -1)
📝 src/workbook.c (+8 -8)

📄 Description

We use libxlswriter in R, but we are not supposed to use fprintf(stderr, ...) because applications and IDEs that embed the R interpreter ignore this. Instead the interpreter has a function REprintf(...) which packages call for text that the IDE or embedding application has to print to the user terminal.

So I would need some way to override the error-printing function, either at build time or at runtime. Here is a simple concept solution. This would allow me to compile libxlsxwriter with

CFLAGS += -DLXW_PRINT_ERR=REprintf

And thereby I get the desired behavior. Alternatively you could create some sort of set-callback, but that would be more involved.

The drawback of this approach I suppose is that variadic macros require c99, which is not a problem for me, but I don't know how else I would do this.

Thanks for you thoughts!


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/jmcnamara/libxlsxwriter/pull/273 **Author:** [@jeroen](https://github.com/jeroen) **Created:** 2/16/2020 **Status:** ❌ Closed **Base:** `master` ← **Head:** `printerr` --- ### 📝 Commits (1) - [`055643d`](https://github.com/jmcnamara/libxlsxwriter/commit/055643d797aced68aa35457ffa0f0f7aa6d7b681) Use single macro for printing to stderr ### 📊 Changes **3 files changed** (+22 additions, -19 deletions) <details> <summary>View changed files</summary> 📝 `include/xlsxwriter/common.h` (+13 -10) 📝 `src/Makefile` (+1 -1) 📝 `src/workbook.c` (+8 -8) </details> ### 📄 Description We use libxlswriter in R, but we are not supposed to use `fprintf(stderr, ...)` because applications and IDEs that embed the R interpreter ignore this. Instead the interpreter has a function `REprintf(...)` which packages call for text that the IDE or embedding application has to print to the user terminal. So I would need some way to override the error-printing function, either at build time or at runtime. Here is a simple concept solution. This would allow me to compile libxlsxwriter with CFLAGS += -DLXW_PRINT_ERR=REprintf And thereby I get the desired behavior. Alternatively you could create some sort of set-callback, but that would be more involved. The drawback of this approach I suppose is that variadic macros require c99, which is not a problem for me, but I don't know how else I would do this. Thanks for you thoughts! --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
gitea-mirror 2026-05-05 12:16:23 -06:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github-starred/libxlsxwriter#455
No description provided.