2022-12-25 03:27 AM
2022-12-25 04:10 AM
Why? printf and scanf work great in c++. # include <cstdio>
2022-12-25 04:39 AM
2022-12-25 04:40 AM
2022-12-25 12:57 PM
You cannot use a C++ include file in a plain C file. main.c is a plain C file.
2022-12-25 07:00 PM
2022-12-25 07:58 PM
> i need to change the setting in properties -> c\c++ build-> setting ->
This works for me with libraries provided in CubeIDE and your PUTCHAR_PROTOTYPE above, without any changes in settings:
// File: testcpp.cpp
#include <cstdio>
// call this from your main.c
extern "C"
void test_cpp(void)
{
printf("hello c++ %d\n", 42);
}
Getting a bit fancier.... the following works too, with language standard ISO C++17:
#include <cstdio>
using std::printf;
extern "C"
void test_cpp(void)
{
printf("hello c++ %d\n", 42);
}
2022-12-26 06:13 AM
Use printo("text", double, float, uint(8-16-32-64)_t, int(8-16-32-64)_t ). Any parameters without restrictions, in any order.
https://github.com/AVI-crak/Rtos_cortex/blob/master/sPrint.h
Before using, define the string output function - soft_print(char* txt)
Works very fast.
2022-12-26 11:26 PM
now kept in
/* USER CODE BEGIN PFP */
#ifdef __GNUC__
#define PUTCHAR_PROTOTYPE int __io_putchar(int ch)
#else
#define PUTCHAR_PROTOTYPE int fputc(int ch, FILE *f)
#endif
PUTCHAR_PROTOTYPE
{
HAL_UART_Transmit(&huart1, (uint8_t *)&ch, 1, HAL_MAX_DELAY);
return ch;
}
void test_cpp(void);
/* USER CODE END PFP */
/* USER CODE BEGIN 4 */
while (1)
2022-12-27 02:24 AM
hi pavel, i was try with many times . since it's working with you can share exact location i need keep and calling .