Skip to content

Commit 240758d

Browse files
committed
Minimal Console: Fix compilation error
Build successfully when `platform.stdio-convert-tty-newlines` or `platform.stdio-convert-newlines` are set to `true` by ensuring `isatty()` is also included when `platform.stdio-minimal-console-only` is set to `true`.
1 parent d5f813b commit 240758d

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

platform/mbed_retarget.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -573,10 +573,10 @@ extern "C" {
573573
ssize_t write(int fildes, const void *buf, size_t nbyte);
574574
ssize_t read(int fildes, void *buf, size_t nbyte);
575575
int fsync(int fildes);
576+
int isatty(int fildes);
576577
#if !MBED_CONF_PLATFORM_STDIO_MINIMAL_CONSOLE_ONLY
577578
off_t lseek(int fildes, off_t offset, int whence);
578579
int ftruncate(int fildes, off_t length);
579-
int isatty(int fildes);
580580
int fstat(int fildes, struct stat *st);
581581
int fcntl(int fildes, int cmd, ...);
582582
int poll(struct pollfd fds[], nfds_t nfds, int timeout);

platform/source/mbed_retarget.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -915,17 +915,13 @@ extern "C" int PREFIX(_istty)(FILEHANDLE fh)
915915
extern "C" int _isatty(FILEHANDLE fh)
916916
#endif
917917
{
918-
#if !MBED_CONF_PLATFORM_STDIO_MINIMAL_CONSOLE_ONLY
919918
return isatty(fh);
920-
#else
921-
// Is attached to an interactive device
922-
return 1;
923-
#endif // !MBED_CONF_PLATFORM_STDIO_MINIMAL_CONSOLE_ONLY
924919
}
925920

926-
#if !MBED_CONF_PLATFORM_STDIO_MINIMAL_CONSOLE_ONLY
921+
927922
extern "C" int isatty(int fildes)
928923
{
924+
#if !MBED_CONF_PLATFORM_STDIO_MINIMAL_CONSOLE_ONLY
929925
FileHandle *fhc = mbed_file_handle(fildes);
930926
if (fhc == NULL) {
931927
errno = EBADF;
@@ -939,8 +935,11 @@ extern "C" int isatty(int fildes)
939935
} else {
940936
return tty;
941937
}
942-
}
938+
#else
939+
// Is attached to an interactive device
940+
return 1;
943941
#endif // !MBED_CONF_PLATFORM_STDIO_MINIMAL_CONSOLE_ONLY
942+
}
944943

945944
extern "C"
946945
#if defined(__ARMCC_VERSION)

0 commit comments

Comments
 (0)