HI Neerav,
Below you can find what worked for me.
1) Add the following macros in C:\Freescale\Freescale_MQX_4_1\config\<board>\user_config.h
o #define MQX_SUPPRESS_FILE_DEF 1
o #define BSPCFG_ENABLE_CPP 1
o #define MQX_SUPPRESS_STDIO_MACROS 1
MQX_SUPRESS_FILE_DEF disables definition of FILE. EWL has its own FILE with different meaning, thus, EWL should link with EWL’s FILE, MQX should link with MQX_FILE, but the linking order is only one – you either take FILE from MQX or from EWL. Therefore we disable, with this macro, MQX to define FILE. Then MQX has to use MQX_FILE and EWL can continue using EWL FILE.
BSPCFG_ENABLE_CPP enables EWL functions required when using c++.
MQX_SUPRESS_STDIO_MACROS Similar as MQX_SUPRESS_FILE_DEF, stdio macros are different files (MQX_FILE) than EWL definitions, different pointer in memory and different structure members. Then, MQX must use its own definitions.
2) Now, stdin, stdout and stderr definitions must be redefined. To do this there are 2 options.
A) The correct way would be to add the following macros in C:\Freescale\Freescale_MQX_4_1\mqx\source\include\fio.h. Recompile BSP and PSP (C:\Freescale\Freescale_MQX_4_1\mqx\build\cw10gcc\bsp_<board> and C:\Freescale\Freescale_MQX_4_1\mqx\build\cw10gcc\psp_<board>). Errors will appear, go to each of them and replace stdin for _mqxio_stdin and stdout for _mqxio_stdout. Recompile again, no errors should appear this time.
o #define _mqxio_stdin (MQX_FILE_PTR)_io_get_handle(IO_STDIN)
o #define _mqxio_stdout (MQX_FILE_PTR)_io_get_handle(IO_STDOUT)
o #define _mqxio_stderr (MQX_FILE_PTR)_io_get_handle(IO_STDERR)
B) A work around would be to force the project to use stdin, stdout and stderr by taking these defines out of the #if directive. With the default build settings the linker will use the MQX definitions, the side effect is that after recompiling BSP and PSP warnings will appear alerting that these macros are redefined.
1) 3) Now you can create a new C++ project. Go to menu > File > New > MQX4.1 Project and in the Wizard “Select Application type and template” window select Examples Application > Basic examples > cplus
4) In menu Project > Properties > C/C++ Build > Settings > ARM Ltd Windows GCC C++ Compiler > Directories add "${MCUToolsBaseDir}/ARM_EABI_Support/ewl/EWL_C++/include" and put the below paths at the end of the Compiler Directories list.
o "${MCUToolsBaseDir}/ARM_EABI_Support/ewl/EWL_C++/include"
o "${MCUToolsBaseDir}/ARM_EABI_Support/ewl/EWL_C/include"
5) Then in menu Project > Properties > C/C++ Build > Librarian check "Enable automatic library configurations" and choose "Model" = ewl_c++ / int / int.
6) Finally, if you replaced stdout for _mqxio_stdout (in step 2) you need to do the same in cplus.cpp and build the project.
Hope this helps.
Carlos