yhirose / cpp-peglib

A single file C++ header-only PEG (Parsing Expression Grammars) library
MIT License
879 stars 112 forks source link

sprintf is deprecated warning #253

Closed kkayal closed 1 year ago

kkayal commented 1 year ago

I have encountered the following warning. I am using AppleClang 14.0.0.14000029

peglib.h:4804:13: warning: 'sprintf' is deprecated: This function is provided for compatibility reasons only. Due to security concerns inherent in the design of sprintf(3), it is highly recommended that you use snprintf(3) instead. [-Wdeprecated-declarations] sprintf(buff, "%4s %10s %5s %10.2f %10.2f %s", "", "", "", ^ /Library/Developer/CommandLineTools/SDKs/MacOSX13.0.sdk/usr/include/stdio.h:188:1: note: 'sprintf' has been explicitly marked deprecated here __deprecated_msg("This function is provided for compatibility reasons only. Due to security concerns inherent in the design of sprintf(3), it is highly recommended that you use snprintf(3) instead.") ^ /Library/Developer/CommandLineTools/SDKs/MacOSX13.0.sdk/usr/include/sys/cdefs.h:215:48: note: expanded from macro '__deprecated_msg'

define deprecated_msg(_msg) attribute((deprecated__(_msg)))

I have replaced sprintfwith snprintf at line 4800, 4804 and 4814 of my local copy as follows:

snprintf(buff, BUFSIZ, ...

This solved the warning

yhirose commented 1 year ago

Thanks for your contribution!