Enabling missing C++11 functionality

If you have any questions on programming, this is the place to ask them, whether you're a newbie or an experienced programmer. Discussion on programming in general is also welcome. We will help you with programming homework, but we will not do your work for you! Any porting requests must be made in Developmental Ideas.
Post Reply
kazade
Insane DCEmu
Insane DCEmu
Posts: 128
Joined: Tue May 02, 2017 3:11 pm
Has liked: 1 time
Been liked: 8 times

Enabling missing C++11 functionality

Post by kazade » Sun Jun 09, 2019 2:19 pm

There are a few C++11 functions that don't exist in the KOS toolchain, specifically things like std::tostring and std::stoi.

For ages I thought that was because G++ 4.7.3 had an incomplete C++11 implementation, but it's actually because they are being #ifdef'd away during the toolchain build. I've tracked everything down to this test in acinclude.m4

Code: Select all

    # Check for the existence in <stdio.h> of vscanf, et. al.
    AC_MSG_CHECKING([for ISO C99 support in <stdio.h> for C++11])
    AC_CACHE_VAL(glibcxx_cv_c99_stdio_cxx11, [
      GCC_TRY_COMPILE_OR_LINK(
        [#include <stdio.h>
         #include <stdarg.h>
         void foo(char* fmt, ...)
         {
           va_list args; va_start(args, fmt);
           vfscanf(stderr, "%i", args);
           vscanf("%i", args);
           vsnprintf(fmt, 0, "%i", args);
           vsscanf(fmt, "%i", args);
           snprintf(fmt, 0, "%i");
         }], [],
        [glibcxx_cv_c99_stdio_cxx11=yes], [glibcxx_cv_c99_stdio_cxx11=no])
    ])
    AC_MSG_RESULT($glibcxx_cv_c99_stdio_cxx11)
    if test x"$glibcxx_cv_c99_stdio_cxx11" = x"yes"; then
      AC_DEFINE(_GLIBCXX11_USE_C99_STDIO, 1,
        [Define if C99 functions or macros in <stdio.h> should be imported
        in <cstdio> in namespace std for C++11.])
fi
Does anyone know why that check will fail, and how it can be made to pass?
kazade
Insane DCEmu
Insane DCEmu
Posts: 128
Joined: Tue May 02, 2017 3:11 pm
Has liked: 1 time
Been liked: 8 times

Re: Enabling missing C++11 functionality

Post by kazade » Tue Jun 11, 2019 1:51 pm

I've upgraded newlib to 2.4 I hoped that would fix this.. it didn't...

Anyone got any ideas? :(
User avatar
BlueCrab
The Crabby Overlord
The Crabby Overlord
Posts: 5387
Joined: Mon May 27, 2002 11:31 am
Location: Sailing the Skies of Arcadia
Has liked: 1 time
Been liked: 12 times
Contact:

Re: Enabling missing C++11 functionality

Post by BlueCrab » Tue Jun 11, 2019 6:33 pm

Honestly, that's the first thing I would have suggested as a possibility to try to fix it... Is there anything in the config.log to show why it's failing (like the actual compiler error it's throwing out)?
Post Reply