Skip to content

Commit d2630d7

Browse files
committed
lib: sgp4: fix strtok_r availability on native_sim
Define `_POSIX_C_SOURCE 200809L` in `sgp4_pass_predict.c` to make `strtok_r` available via picolibc without needing a manual forward declaration. Remove the now-redundant `strtok_r` declarations from the test files. Signed-off-by: Simen S. Røstad <simen.rostad@nordicsemi.no>
1 parent f971ad2 commit d2630d7

3 files changed

Lines changed: 6 additions & 4 deletions

File tree

lib/sgp4/sgp4_pass_predict.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
55
*/
66

7+
#ifdef _POSIX_C_SOURCE
8+
#undef _POSIX_C_SOURCE
9+
#endif
10+
/* Required for strtok_r() on native_sim / picolibc. */
11+
#define _POSIX_C_SOURCE 200809L
12+
713
#include <string.h>
814
#include <stdint.h>
915
#include <stdlib.h>

tests/lib/ntn-sib32/src/test_sib32_tle.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717

1818
/* missing headers */
1919
struct tm *gmtime_r(const int64_t *timep, struct tm *result);
20-
char *strtok_r(char *str, const char *delim, char **saveptr);
21-
2220

2321
DEFINE_FFF_GLOBALS;
2422

tests/lib/ntn/src/sgp4_pass_test.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717

1818
/* missing headers */
1919
struct tm *gmtime_r(const int64_t *timep, struct tm *result);
20-
char *strtok_r(char *str, const char *delim, char **saveptr);
21-
2220

2321
DEFINE_FFF_GLOBALS;
2422

0 commit comments

Comments
 (0)