Project

General

Profile

Task #600

Allow snprintf() usage on all platforms

Added by Teemu Murtola almost 10 years ago. Updated about 7 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
core library
Target version:
Difficulty:
uncategorized
Close

Description

snprintf() is only included in C99, not in C89 or the C++ standard, and of course, doesn't work (or at least didn't work a year ago when I tested) in the Visual Studio C compiler... However, it would be immensely useful, both for security and reliability, to be able to use it in many places in the code (it's very difficult to format output for storage in a string safely without snprintf()). A workaround would be very useful (or a confirmation that it actually works in VC, at least in the C++ mode); I think that Visual Studio provides a _snprintf() function that differs a bit in the return value, but would still be better than nothing.

History

#1 Updated by Teemu Murtola almost 10 years ago

Sander's commit 02dd4b31130b63f580f6da6156214f6611433819 now allows basic usage of snprintf() on Windows as well; we might also want to write an additional wrapper (possibly only in the master branch once C++ is enabled to avoid manual memory management in the caller) that allocates the output buffer dynamically to fit the message, hiding the different return value semantics on different platforms.

#2 Updated by Rossen Apostolov about 9 years ago

  • Assignee deleted (Erik Lindahl)
  • Target version deleted (git master)

#3 Updated by Teemu Murtola about 9 years ago

  • Tracker changed from Bug to Task
  • Status changed from New to In Progress
  • Target version set to 5.0

62a85d4 introduced a simple wrapper for snprintf(), but it should still be tested that it compiles and works on all necessary platforms.

#4 Updated by Teemu Murtola over 8 years ago

  • Category deleted (mdrun)
  • Status changed from In Progress to Closed
  • Assignee set to Teemu Murtola

With Jenkins, I think that the code added in the mentioned commit is sufficient to close this issue.

#5 Updated by Teemu Murtola about 7 years ago

  • Category set to core library

Also available in: Atom PDF