Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with vsprintf(), no float printed or conflict #7

Closed
rei-vilo opened this issue Nov 16, 2019 · 3 comments
Closed

Issue with vsprintf(), no float printed or conflict #7

rei-vilo opened this issue Nov 16, 2019 · 3 comments

Comments

@rei-vilo
Copy link
Member

Results for the basic example sketch calling vsprintf() are:

=== Test of vsprintf on LPSTK
numberF =
number32 = 123456

The float isn't printed.
Adding -Dprintf=iprintf has no impact.
Adding -Dprintf=fprintf results in a conflict with

In file included from /Users/ReiVilo/Library/Energia15/packages/energia/tools/arm-none-eabi-gcc/6.3.1-20170620/arm-none-eabi/include/string.h:10:0,
                 from /Users/ReiVilo/Library/Energia15/packages/energia/hardware/cc13x2/5.29.0-beta2/cores/cc13x2/ti/runtime/wiring/Energia.h:38,
                 from main.cpp:30:
/<command-line>:1:8: conflicting declaration of C function 'int fprintf(const char*, ...)'
/Users/ReiVilo/Library/Energia15/packages/energia/tools/arm-none-eabi-gcc/6.3.1-20170620/arm-none-eabi/include/stdio.h:196:5: previous declaration 'int fprintf(FILE*, const char*, ...)'
 int _EXFUN(fprintf, (FILE *__restrict, const char *__restrict, ...)
     ^
  • Code of the basic example sketch
#include "Energia.h"

// Functions
#include "stdarg.h"
#include "stdio.h"
char bufferOut[128];

String formatString(const char * format, ...)
{
    va_list args;
    va_start(args, format);
    vsprintf(bufferOut, format, args);
    va_end(args);
    return String(bufferOut);
}

// Add setup code
// !!! Help: http://bit.ly/2BmKRzI
void setup()
{
    Serial.begin(115200);
    Serial.println("=== Test of vsprintf on LPSTK");
    uint32_t number32 = 123456;
    float numberF = 1234.56;
    
    Serial.println(formatString("%-10s= %8.2f", "numberF", numberF));
    Serial.println(formatString("%-10s= %8i", "number32", number32));

    
}

// Add loop code
void loop()
{

}
@rei-vilo
Copy link
Member Author

Tested with both arm-none-eabi-gcc (GNU Tools for ARM Embedded Processors 6-2017-q2-update) 6.3.1 20170620 (release) [ARM/embedded-6-branch revision 249437]and arm-none-eabi-gcc (GNU Tools for Arm Embedded Processors 8-2019-q3-update) 8.3.1 20190703 (release) [gcc-8-branch revision 273027], to no avail.

@rei-vilo
Copy link
Member Author

rei-vilo commented Nov 24, 2019

Same issue, same solution.

See energia/msp432r-core#17 and -Wl,-u,_printf_float,-u,-_scanf_float

@rei-vilo
Copy link
Member Author

See #11

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant