cancel
Showing results for 
Search instead for 
Did you mean: 

Why does getdate(char*) not compile in STM32CubeIDE? I cannot find an option to enable it. Is there abother way of char* to tm struct?

MEdgerton
Senior

I see that the standard time.h is included. But getdate to convert a char* to tm does not coliple as it is not enabled. I have tried various project options with no joy.

Can someone let me know how to do this?

6 REPLIES 6

Doesn't compile, or doesn't link?

Assuming the latter you need to link against a full library not some limited, lite or cut-down one.

grep the library directory to find which, if any, contain the function.

Sure you could find some source if you looked too, and integrate that into the project.

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
berendi
Principal

Use strptime instead.

#define _XOPEN_SOURCE
#include <time.h>
/* ... */
struct tm tm;
strptime("2001-11-12 18:31:01", "%Y-%m-%d %H:%M:%S", &tm);

_XOPEN_SOURCE must be defined before the very first #include directive, not just before including <time.h>.

Thank you, I found this but it generates a compiler warning " warning: implicit declaration of function 'strptime'; did you mean 'strftime'? [-Wimplicit-function-declaration]".

is there a way to stop this. I try to keep warnings to 0 so I can see any that may actually cause a problem when running.

Again,

_XOPEN_SOURCE must be defined before the very first #include directive, not just before including <time.h>

What is the first non-comment line in the source file in which strptime() is called?

MEdgerton
Senior

Many thanks, I used strptime and it works well.

Hasdf.1
Associate

I determined this however it generates a compiler warning caution. implicit declaration of characteristic guidedid you mean strftime? Wimplicit function-statement