This is the mail archive of the mailing list for the libstdc++ project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Question on enabling c++ to_string to arm-none-eabi target

Hi there,

I just cross build a tool chain using latest trunk code on x86 for
arm-none-eabi. The C library is Newlib trunk. When compile below case:

#include <string>

int main()
        return 0;

with command "arm-none-eabi-g++  -mthumb -mcpu=cortex-m4  -std=c++11
-S -O2", I got errors: In function 'int main()': error: 'to_string' is not a member of 'std'

I then did some search and found it is because the macro
_GLIBCXX_USE_C99 isn't defined in H file
arm-none-eabi/include/c++/4.9.0/arm-none-eabi/bits/c++config.h. To get
this macro defined, below piece of code needs to be successfully
compiled during the configuration of libstdc++-v3:

| #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);
|       }
| int
| main ()
| {
| snprintf("12", 0, "%i");
|   ;
|   return 0;
| }

The stdio.h from Newlib defines vscanf function as:

#if !defined(__STRICT_ANSI__) || (__STDC_VERSION__ >= 199901L)
int     _EXFUN(vscanf, (const char *, __VALIST)
               _ATTRIBUTE ((__format__ (__scanf__, 1, 0))));

And the libstdc++-v3 configuration always uses option -std=c++98 to
compile above code, this option indicate the define of
__STRICT_ANSI__. So always fail to compile above code with error

conftest.cpp:36:19: error: 'vscanf' was not declared in this scope
  vscanf("%i", args);

Finally failing to compile the conftest.cpp causes the disable of c++
to_string function. So what should I do to let those conftest.cpp
pass? By changing option from -std=c++98 to -std=gnu++98 or removing
the IF macros from stdio.h? Please help. Thanks in advance.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]