Loading...
 

Zephyr project on STM32

   Zephyr Workbench, a VSCode extension to manage Zephyr on STM32.
It enables users to easily create, develop, and debug Zephyr applications.
Main features:
  • Install host dependencies.
  • Import toolchain and SDK.
  • Create, configure, build and manage apps.
  • Debug STM32.
You can directly download it from the VSCode marketplace
For more details, visit the Zephyr Workbench

System Workbench for STM32


Enabling Strict ANSI compile?

Hi all,
I’m not very familiar with compile time options and I’m not sure how to proceed.

For my project I want a function similar to ftoa (float to ascii), and I found in stdlib.h:

char * _EXFUN(gcvt,(double,int,char *));
char * _EXFUN(gcvtf,(float,int,char *));
char * _EXFUN(fcvt,(double,int,int *,int *));
char * _EXFUN(fcvtf,(float,int,int *,int *));
char * _EXFUN(ecvt,(double,int,int *,int *));
char * _EXFUN(ecvtbuf,(double, int, int*, int*, char *));
char * _EXFUN(fcvtbuf,(double, int, int*, int*, char *));
char * _EXFUN(ecvtf,(float,int,int *,int *));
char * _EXFUN(dtoa,(double, int, int, int *, int*, char**));

All of which I would like to try, but they’re enclosed within #ifndef STRICT_ANSI.
So how do I compile as strict ansi? What I’ve tried so far is to create a copy of debug configuration and add “ansi” (also tried -ansi) as build variable under Project properties -> C/C++ Build -> Build Variables. Did not make any difference, still get the “no reference to function found”.

Thank you.

Okay, so I found a way to use C90 standard in Project Properties -> C/C++ Build -> Settings -> Tool Settings tab -> MCU GCC Compiler -> Dialect -> Language Standard.

But given the grief it gave me about coding style all around even in CMSIS and HAL I definitely am not compiling like this :-)

So any hints on a suitable float to ascii function is appreciated!


France

Hi,

Currently when you select the dialect there, you can only select ISO standard conformance, which is a lot more strict than the standard gnu settings. You can select gnu-C-90 dialect by letting the dialect unspecified in the “Language Standard” menu, but adding “-std=gnu90” in the “Other dialect flags” box (or any other supported dialect, see the C Compiler documentation in Other Manuals)

Bernard (Ac6)


Thank you for answering, Bernard.

adding -std=gnu90 in the “Other dialect flags” box compiled fine. But it did not seem to trigger the #ifndef STRICT_ANSI.

By the way, for some reason, when I try to use dtoa I get the “undefined reference to ´dtoa’ ” error. But if I try to use gcvtf which is defined right next to dtoa in stdlib.h I only get the warning “implicit declaration of function ´gcvtf’ “.

I’m looking through GCC 5.3.0 manual but I can’t figure out where to find help with usage of the functions, or their implementations? It’s not like Cube HAL where you would just open stdlib.c and read the comments above the gcvtf implementation, for instance :-)


> I’m looking through GCC 5.3.0 manual but I can’t figure out where to find help with usage of the functions, or their implementations?

Those are not compiler-specific functions, those are standard C library functions, look in your libc documentation/reference.

BTW, why don’t you use the more common and well-known snprintf function?

FYI, gcvt and family are marked as LEGACY in POSIX.1-2001. POSIX.1-2008 removes the specification of gcvt(), recommending the use of sprintf(3) instead (though snprintf(3) may be preferable).


bugmenot, thank you for clarifying. It did come to me that I was looking in the compiler manual for something that is not compiler specific.
I will use snprintf. I was not aware of this, and will be testing later today. Thanks again.


Thanks for the tips! Unfortunately -u _printf_float and snprintf ate so much flash I have to make something simpler and faster myself.

 

Newest Forum Posts

  1. reservation car service Seattle by Jamesprede, 2025-05-01 10:06
  2. Last day: drone bonus by Danielrug, 2025-04-19 16:55
  3. SPI on Nucleo_STMH533RE by higginsa1, 2025-03-25 07:37
  4. SPI on Nucleo_STMH533RE by royjamil, 2025-03-23 11:31
  5. SPI on Nucleo_STMH533RE by higginsa1, 2025-03-23 09:33
  6. Configuring DMA for ADC in SW? by sam.hodgson, 2025-03-04 12:58
  7. Insightful Perspectives on This Subject by davidsycle, 2025-03-04 05:45
  8. Build a project in "release" mode by info@creosrl.it, 2025-02-20 18:12
  9. Build a project in "release" mode by info@creosrl.it, 2025-02-20 17:05
  10. Build a project in "release" mode by tang, 2025-02-20 10:36

Last-Modified Blogs