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

  • 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.
  • I now have the kind of aws_iot project and added this in prj.conf to make it work with long longs and floats.

    CONFIG_NEWLIB_LIBC=y 
    CONFIG_MINIMAL_LIBC_LL_PRINTF=y
    CONFIG_NEWLIB_LIBC_FLOAT_PRINTF=y
    CONFIG_FPU=y

Related