Unable to print long long

I am unable to print a long long. As a simple test I tried to print this:

			uint64_t long_num1 = 0x10000000000;
			printk("%llu\n", long_num1);

			int64_t long_num2 = 0x10000000000;
			printk("%lld\n", long_num2);

			int64_t long_num3 = 0x10000000000;
			printk("%lli\n", long_num3);

All three will print 0.

I am using version 2.5.0 and added this to my prj.conf, also tried it with only CONFIG_NEWLIB_LIBC=y to start with, don't know what I am doing wrong, float is also a problem at the moment:

CONFIG_NEWLIB_LIBC_NANO=n
CONFIG_NEWLIB_LIBC=y
CONFIG_MINIMAL_LIBC_LL_PRINTF=y

Parents Reply Children
  • If you set CONFIG_NEWLIB_LIBC in prj.conf, and it is ignored, you should get a warning in the build log.

    I like to debug this using "west build -t menuconfig", then you can see how dependencies are set if you search for an option("/") and then press "?" for more info on the option.

    Try to also add "CONFIG_NEWLIB_LIBC_FLOAT_PRINTF=y" to Asset Tracker v2 and see if that works.

  • I have this warning in Visual Studio code when I hover the setting but this warning is also in the hello world example that does work.

    CONFIG_NEWLIB_LIBC was assigned the value y, but got the value n. Missing dependencies:
    NEWLIB_LIBC_SUPPORTED

    This would be a glitch in Visual Studio code according to this.

    (+) Updating from 2.3 to v2.5 errors - Nordic Q&A - Nordic DevZone - Nordic DevZone (nordicsemi.com)

    The Asset Tracker v2 with the floats works, I tried this before at the LTE course exercise.

    When I try to use "west build (-t menuconfig)" I get the message "FATAL ERROR: CMake is not installed or cannot be found; cannot build."

  • ralphvn said:
    The Asset Tracker v2 with the floats works, I tried this before at the LTE course exercise.

    Nice!

    ralphvn said:
    When I try to use "west build (-t menuconfig)" I get the message "FATAL ERROR: CMake is not installed or cannot be found; cannot build."

    Not important to make this work. If you want to give it a second try, you can choose menuconfig from the three dots next to the"nRF Kconfig GUI" action in VS Code.

    ralphvn said:
    This would be a glitch in Visual Studio code according to this.

    I also saw this when I tried to reproduce your issue on my end, so I have reported this to our VS Code developers.

    Thanks for mentioning the potential bug!

  • When I add CONFIG_NEWLIB_LIBC=y to the Asset Tracker v2 it does not compile anymore, it gives me this warning, I think the kind of warning you meant previously.

    warning: CJSON_LIB (defined at C:/ncs/v2.5.99-dev1/nrf/modules/cjson/Kconfig:7) has direct dependencies (NEWLIB_LIBC && NEWLIB_LIBC_FLOAT_PRINTF) || EXTERNAL_LIBC || PICOLIBC with value n, but is currently being y-selected by the following symbols:
     - NRF_CLOUD_MQTT_CHOICE (defined at C:/ncs/v2.5.99-dev1/nrf\subsys\net\lib\nrf_cloud\Kconfig.nrf_cloud_mqtt:10), with value y, direct dependencies y (value: y)
     - NRF_CLOUD_FOTA (defined at C:/ncs/v2.5.99-dev1/nrf\subsys\net\lib\nrf_cloud\Kconfig.nrf_cloud_fota:6), with value y, direct dependencies y (value: y)
     - NRF_CLOUD_AGNSS (defined at C:/nordic/asset_tracker_v2\src/modules/Kconfig.cloud_module:18, C:/ncs/v2.5.99-dev1/nrf\subsys\net\lib\nrf_cloud\Kconfig.nrf_cloud_agnss:6), with value y, direct dependencies (LOCATION_MODULE && CLOUD_MODULE) || (MODEM_INFO && MODEM_INFO_ADD_NETWORK) (value: y), and select condition MODEM_INFO && MODEM_INFO_ADD_NETWORK (value: y)
     - NRF_CLOUD_LOCATION (defined at C:/nordic/asset_tracker_v2\src/modules/Kconfig.cloud_module:44, C:/ncs/v2.5.99-dev1/nrf\subsys\net\lib\nrf_cloud\Kconfig.nrf_cloud_location:6), with value y, direct dependencies (NRF_CLOUD_MQTT && CLOUD_MODULE) || NRF_CLOUD_MQTT (value: y), and select condition NRF_CLOUD_MQTT (value: y)
    
    error: Aborting due to Kconfig warnings

  • Sigurd Hellesvik said:
    Try to also add "CONFIG_NEWLIB_LIBC_FLOAT_PRINTF=y" to Asset Tracker v2 and see if that works.
Related