Forums - Certain Standard Libc functions not working

2 posts / 0 new
Last post
Certain Standard Libc functions not working
asad.islam
Join Date: 8 Nov 19
Posts: 2
Posted: Wed, 2020-01-15 09:03

Hi,

I am using the Snapdragon LLVM ARM C/C++ toolchain version 4.0.3. The hardware is a Quectel BG96 chip. 
The functionality that fails is converting string to number. If you use "
strtod" or "strtol" and use the string "123", you get correct values. But if using string "a" then instead of failing to parse, the code gets stuck. The device doesnt crash or anything, its just the compiled application stops working.

Currently there is no way to fix it except to manally check the first character.

Thanks,
Asad

  • Up0
  • Down0
mlokowich
Join Date: 6 Jan 13
Posts: 2
Posted: Sat, 2020-05-23 07:01

I experienced the same problem, thought it was a bug in the musl library, but even replacing that would crash the strtox family of functions.  My solution was to override with my own functions.  Use wrap naming and linker command:

long __wrap_strtol(const char *__restrict nptr,
                   char **__restrict endptr, int base)
 
-Wl,-wrap=strtol
 
 
 
  • Up0
  • Down0
or Register

Opinions expressed in the content posted here are the personal opinions of the original authors, and do not necessarily reflect those of Qualcomm Incorporated or its subsidiaries (“Qualcomm”). The content is provided for informational purposes only and is not meant to be an endorsement or representation by Qualcomm or any other party. This site may also provide links or references to non-Qualcomm sites and resources. Qualcomm makes no representations, warranties, or other commitments whatsoever about any non-Qualcomm sites or third-party resources that may be referenced, accessible from, or linked to this site.