[NECTO Studio 2.0] Is there support for sprintf and similar functions?

Cross-platform IDE for the rapid development of applications for the embedded world, available on Windows, Linux, and macOS.
Post Reply
Author
Message
frank.malik
Posts: 96
Joined: 09 Apr 2021 20:37

[NECTO Studio 2.0] Is there support for sprintf and similar functions?

#1 Post by frank.malik » 14 Jul 2022 08:21

Hello,

I just wrote a standard program and the compiler complains about "sprintf".

Undeclared identifier 'sprintf' in expression

This is the code snippet with the error message.

Code: Select all

            for (int mask = 0x80; mask > 0; mask >>= 1)
            {
                length +=  sprintf (Buffer + length, " %d ;", ((mask & value) == 0) ? 0 : 1);
            }
Please give guideance.
with best regards
Frank
Kind regards
Frank

Fusion for STM32 v8, STM32F407ZG@168MHz, 4" TFT capacitive
mikromedia 3, PIC32MZ2048EFH100@200MHz, 3" TFT capacitive
NECTO Studio 3.0.0, mikroC AI for ARM/PIC32, mikroSDK v.2.7.2

sgssn
Posts: 35
Joined: 13 Sep 2021 16:24

Re: [NECTO Studio 2.0] Is there support for sprintf and similar functions?

#2 Post by sgssn » 15 Jul 2022 11:55

Hello
i think the necessary header file is missing. Try

#include <stdio.h>

There sprintf should be included

regards
Gerhard

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: [NECTO Studio 2.0] Is there support for sprintf and similar functions?

#3 Post by filip » 15 Jul 2022 13:18

Hi,

Also, if you are using legacy libraries, you need to check the sprintf library box in the Library Manager.

Regards,
Filip.

frank.malik
Posts: 96
Joined: 09 Apr 2021 20:37

Re: [NECTO Studio 2.0] Is there support for sprintf and similar functions?

#4 Post by frank.malik » 15 Jul 2022 20:30

Hello Filip,

thanks for your feedback. I think you are correct that usually functions like sprintf are defined in stdio.h.
However, under NECTOStudio\compilers\ARM\mikroC\include\ the library stdio.h is almost empty.

Code: Select all

#ifndef __stdio_h
#define __stdio_h

#endif
Who is usually providing these libraries?
kind regards
Frank
Kind regards
Frank

Fusion for STM32 v8, STM32F407ZG@168MHz, 4" TFT capacitive
mikromedia 3, PIC32MZ2048EFH100@200MHz, 3" TFT capacitive
NECTO Studio 3.0.0, mikroC AI for ARM/PIC32, mikroSDK v.2.7.2

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: [NECTO Studio 2.0] Is there support for sprintf and similar functions?

#5 Post by filip » 27 Jul 2022 14:01

Hi,

Sprintf is installed with the NECTO Studio in the legacy driver package - \NECTOStudio\NECTOStudio\sdk\legacy\v6.2.0\bin\

You may add the library file in the NECTO Studio project and refer to the Help file :
https://help.mikroe.com/legacy/arm/index.htm

Regards,
Filip.

frank.malik
Posts: 96
Joined: 09 Apr 2021 20:37

Re: [NECTO Studio 2.0] Is there support for sprintf and similar functions?

#6 Post by frank.malik » 28 Jul 2022 15:41

Hi Filip,

thanks very much for your suggestion.

However, maybe you are expecting too much software know-how from me.
How shall I "add the library file in the NECTO Studio project" ?

I assume I have to modify the CMakeLists.txt somehow. But in the end, I would expect a "sprintf.h" header file
to be included in my source code.
In the mentioned directory folder, there are several sub-folders, also one named "__Lib_Sprintf", but nothing
useful inside ( at least not for me, with my knowledge ).
Could you please specify this adding-to-Necto-Studio-project-process a little bit more in detail?

Additionally, I would also like to have sscanf, which should be also part of the stdio.h lib. Where
is this located?

Kind regards
Frank
Kind regards
Frank

Fusion for STM32 v8, STM32F407ZG@168MHz, 4" TFT capacitive
mikromedia 3, PIC32MZ2048EFH100@200MHz, 3" TFT capacitive
NECTO Studio 3.0.0, mikroC AI for ARM/PIC32, mikroSDK v.2.7.2

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: [NECTO Studio 2.0] Is there support for sprintf and similar functions?

#7 Post by filip » 11 Aug 2022 14:30

Hi,

The sprintf and similar function are currently supported in legacy mode, you can search for the .emcl library object file located in the NECTOStudio\NECTOStudio\sdk\legacy\v6.2.0\bin\ folder (for your MCU architecture),
copy to your project folder and add it to the project from the Project Manager

Regards,
Filip.

frank.malik
Posts: 96
Joined: 09 Apr 2021 20:37

Re: [NECTO Studio 2.0] Is there support for sprintf and similar functions?

#8 Post by frank.malik » 09 Sep 2022 10:30

Hi Filip,

I'm still struggling with this problem.

I can't find a good explanation how to include a .memake thing into my cmakelist.txt, or in other words, how to utilize the sprintf legacy library with cmake.
I think this should be a very common issue, but even in this forum there seems to be no good example.

The migration from make to cmake could be something for a tutorial, as a lot of people are using either concept.
Please give me your advice, best would be a short example, how to include the sprintf library in my cmakelist file.

Here is my current cmakelist.txt, used with a mikromedia 3 and a PIC32MZ processor:

Code: Select all

cmake_minimum_required(VERSION 3.21)
if (${TOOLCHAIN_LANGUAGE} MATCHES "MikroC")
    project(Brushless23_PIC32_Display LANGUAGES MikroC)
else()
    project(Brushless23_PIC32_Display  LANGUAGES C ASM)
endif()

include(mikroeUtils)

set(PROJECT_TYPE "designer" CACHE STRING "" FORCE)

add_executable(Brushless23_PIC32_Display
main.c
main_screen.c
main_screen.h
main_screen.mscr
motor.h
brushless23_options.h
motor_act42blf01.h
motor.h
brushless23_screen.c
brushless23_screen.h
__Lib_Sprintf/__Lib_Sprintf.mcl
)

############################ Brushless23_PIC32_Display GENERATED CODE START ###########################
add_subdirectory(lib_brushless23)
target_link_libraries(Brushless23_PIC32_Display PUBLIC Click.Brushless23)
find_package(MikroSDK.VisualTft REQUIRED)
target_link_libraries(Brushless23_PIC32_Display PUBLIC MikroSDK.VisualTft)
find_package(MikroSDK.TouchController REQUIRED)
target_link_libraries(Brushless23_PIC32_Display PUBLIC MikroSDK.TouchController)
find_package(MikroSDK.GraphicLibrary REQUIRED)
target_link_libraries(Brushless23_PIC32_Display PUBLIC MikroSDK.GraphicLibrary)
find_package(MikroC.Core REQUIRED)
target_link_libraries(Brushless23_PIC32_Display PUBLIC MikroC.Core)
############################ Brushless23_PIC32_Display GENERATED CODE END ###########################
designer_generator(Brushless23_PIC32_Display resource.mres main_screen.mscr)
Obviously this couldn't work, as there is no include file for the function definitions of the sprintf library.
Even if I would ( I tried it ), it doesn't recognise the __Lib_Sprintf.mcl content.

Thanks and kind regards
Frank
Kind regards
Frank

Fusion for STM32 v8, STM32F407ZG@168MHz, 4" TFT capacitive
mikromedia 3, PIC32MZ2048EFH100@200MHz, 3" TFT capacitive
NECTO Studio 3.0.0, mikroC AI for ARM/PIC32, mikroSDK v.2.7.2

frank.malik
Posts: 96
Joined: 09 Apr 2021 20:37

Re: [NECTO Studio 2.0] Is there support for sprintf and similar functions?

#9 Post by frank.malik » 13 Sep 2022 11:14

Hello,

the problem is still not solved, my questions unfortunately not answered.
But for all the others who might have a similar problem, I like to suggest the following workaround.

It is not a replacement for sprintf, but gives the possibilitiy to print numbers. I stumbled over it by chance.
You may use the functionality of "Conversions". Please activitate this in the Library Manager.
If you include the file "conversions.h" you can use functions like uint32_to_str and similar.
Kind regards
Frank

Fusion for STM32 v8, STM32F407ZG@168MHz, 4" TFT capacitive
mikromedia 3, PIC32MZ2048EFH100@200MHz, 3" TFT capacitive
NECTO Studio 3.0.0, mikroC AI for ARM/PIC32, mikroSDK v.2.7.2

User avatar
filip
mikroElektronika team
Posts: 11874
Joined: 25 Jan 2008 09:56

Re: [NECTO Studio 2.0] Is there support for sprintf and similar functions?

#10 Post by filip » 27 Sep 2022 15:41

Hi,

We have in plans to add sprint and similar function in NECTO Studio, I am sorry for the inconvenience.

Regards,
Filip.

Post Reply

Return to “IDE”