c - Is calling atoi without stdlib undefined behaviour? -
is calling atoi
without including stdlib.h
undefined behaviour? can't find have included stdlib.h
in project, though have used atoi
. thing atoi
has been working fine - it has been parsing integers correctly every time software has been used. embedded device. there case can defined?
btw. in line:
#ifdef __cplusplus #if __cplusplus extern "c"{ #endif #endif /* __cplusplus */ #include "sdkglob.h" #ifdef __cplusplus #if __cplusplus } #endif #endif /* __cplusplus */
that header includes stdlib.h can't understand in case included. , not sure if cplusplus defined anywhere. c project anyway.
prior c99 acceptable use functions hadn't been declared. compiler might generate warning there no error until linker either didn't find function or found function of same name signature other 1 compiler had guessed. luckily you, compiler guesses return type of int
.
in c99 became necessary function declarations visible not compilers strictly enforce rule.
as per random832's comment, it's quite possible sdkglob
includes stdlib
itself.
as other question: sdkglob
included if run through c++ compiler rather c compiler extern "c"{ .. }
wrapping. tells c++ compiler not mangle names can link against version of module built using ordinary c compiler. it's normal way provide plain c libraries in way allows them used both c , c++ code.
Comments
Post a Comment