HoerTech-gGmbH / openMHA

The open Master Hearing Aid (openMHA)
http://www.openmha.org
GNU Affero General Public License v3.0
252 stars 74 forks source link

sprintf #63

Closed MalcolmSlaney closed 11 months ago

MalcolmSlaney commented 11 months ago

When I compile a fresh copy of openMHA on my Mac running Sonoma (MacOSX 14.1.2) I get the following error message. Is this a known problem and has anybody updated the source to remove sprintf?

I cloned from GitHub and then simply typed the command 'make'.

Thanks.

-- Malcolm

fshift_hilbert.cpp:242:9: error: '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. [-Werror,-Wdeprecated-declarations]
        sprintf(tmp,"[%g,%g]",-frate,frate);
        ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/stdio.h:180: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/MacOSX.sdk/usr/include/sys/cdefs.h:215:48: note: expanded from macro '__deprecated_msg'
        #define __deprecated_msg(_msg) __attribute__((__deprecated__(_msg)))
tobiasherzke commented 11 months ago

sprintf is a dangerous function, but it is not deprecated as the message suggests. Its usage here is ok, as the buffer tmp is large enough to hold the result in all cases.

You are getting this error because you are using newer MacOS header files than we did in the previous release. In these, sprintf is erroneously (but understandably) marked deprecated.

We will most likely fix this for the next release.

As a workaround in the meantime, after you receive this error, open the generated file config.mk in a text editor and remove all occurrences of -Werror. Then retry executing make.