This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

newlib: why cplusplus doesn't support -D_FORTIFY_SOURCE=2

     In the newlib's sys/features.h, the "__SSP_FORTIFY_LEVEL" will not be defined when the

source is cpluspluse.

#if _FORTIFY_SOURCE > 0 && !defined(__cplusplus) && !defined(__lint__) && \
   (__OPTIMIZE__ > 0 || defined(__clang__)) && __GNUC_PREREQ__(4, 1)
#  if _FORTIFY_SOURCE > 1
#    define __SSP_FORTIFY_LEVEL 2
#  else
#    define __SSP_FORTIFY_LEVEL 1
#  endif
#else
#  define __SSP_FORTIFY_LEVEL 0
#endif

(sys/features.h)

    I don't know this is a bug or a feature, but If I remove the '__cplusplus' restrict, is there

any possible problem?

    Because this feature will catch some real bugs in my code, such as strcpy, memcpy...