Preventing KDS from wanting to build main.c instead of main.cpp?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Preventing KDS from wanting to build main.c instead of main.cpp?

977 Views
dave408
Senior Contributor II

I'm generally happy with my progress with converting my C application to C++.  However, it seems that whenever I checkin my code and checkout on a different machine and rebuild, KDS always wants to build main.c and os_tasks.c and execute them, even though those files are explicitly excluded from my project.  I have to manually delete the files from my filesystem in order to force KDS to build the cpp files.

 

Is there a setting that I'm missing somewhere.  I would think that if the file is excluded and the icon shows the slash through it, that KDS would completely ignore the file.

Labels (1)
5 Replies

595 Views
mike1974
Contributor III

Hi Dave,

Don't know if this would work for you, but in my case I just call a C++ function called MainLoop() directly from my main() function in main.c.   I have a file called "MainLoop.h" and "MainLoop.cpp".  In MainLoop.h I have:

#ifdef __cplusplus

extern "C" {

#endif

extern void MainLoop(void);

#ifdef __cplusplus

}  /* extern "C" */

#endif

The extern "C" code allows you to call your C++ MainLoop() (which then calls other C++ code) from your C main() function.

595 Views
dave408
Senior Contributor II

Thanks, Michael, that is definitely a good workaround.  I could do the same thing with os_tasks.c, and have each task in that file call a helper function in my cpp file.  I'll keep this question open until we determine if it's also an issue with KDS.

0 Kudos

595 Views
BlackNight
NXP Employee
NXP Employee

The 'ignored for build' setting is stored in the .cproject file of the project (search for your main.c and you should see it). Could it be that somehow you are not checking in that file properly? And after the check out of your files from the version control, are the make files rebuilt (I hope you have not put the generated make files or any other generated files into the version control system)?

Otherwise, it might be helpful if you could post the output of the console of your build process.

I hope this helps,

Erich

0 Kudos

595 Views
dave408
Senior Contributor II

I wonder if this is a bug?  I didn't even have to move to a different system.  Somehow, it reverted back to compiling main.c and os_tasks.c.

Here's a relevant portion of the build log:

Invoking: Cross ARM C Compiler

arm-none-eabi-gcc -mcpu=cortex-m4 -mthumb -mfloat-abi=hard -mfpu=fpv4-sp-d16 -O0 -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections  -g3 -D"CPU_MK64FN1M0VLL12" -D"FSL_RTOS_MQX" -D"PEX_MQX_KSDK" -I"C:/Code/GCS4000_Firmware/KDS3_OV2/SDK/platform/hal/inc" -I"C:\Freescale\KSDK_1.2.0\middleware\tcpip\rtcs\source\port\phyksz8081" -I"C:\Freescale\KSDK_1.2.0\examples\frdmk64f\demo_apps\lwip\lwip_tcpecho_demo\tcpecho_rtos" -I"C:\Freescale\KSDK_1.2.0\middleware\tcpip\lwip\src\include\lwip" -I"C:\Freescale\KSDK_1.2.0\middleware\tcpip\lwip\src\include\ipv4\lwip" -I"C:\Freescale\KSDK_1.2.0\middleware\tcpip\lwip\src\include\ipv4" -I"C:\Freescale\KSDK_1.2.0\middleware\tcpip\lwip\port" -I"C:/Code/GCS4000_Firmware/KDS3_OV2/SDK/platform/hal/src/sim/MK64F12" -I"C:\Freescale\KSDK_1.2.0\middleware\tcpip\lwip\src\include" -I"C:/Code/GCS4000_Firmware/KDS3_OV2/SDK/platform/system/src/clock/MK64F12" -I"C:/Code/GCS4000_Firmware/KDS3_OV2/SDK/platform/system/inc" -I"C:/Code/GCS4000_Firmware/KDS3_OV2/SDK/platform/drivers/inc" -I"C:/Code/GCS4000_Firmware/KDS3_OV2/SDK/rtos/mqx/mqx/source/psp/cortex_m" -I"C:/Code/GCS4000_Firmware/KDS3_OV2/SDK/rtos/mqx/mqx/source/psp/cortex_m/cpu" -I"C:/Code/GCS4000_Firmware/KDS3_OV2/SDK/rtos/mqx/config/common" -I"C:/Code/GCS4000_Firmware/KDS3_OV2/SDK/rtos/mqx/mqx/source/include" -I"C:/Code/GCS4000_Firmware/KDS3_OV2/SDK/rtos/mqx/mqx/source/bsp" -I"C:/Code/GCS4000_Firmware/KDS3_OV2/SDK/rtos/mqx/mqx/source/psp/cortex_m/compiler/gcc_arm" -I"C:/Code/GCS4000_Firmware/KDS3_OV2/Generated_Code/SDK/rtos/mqx/config/board" -I"C:/Code/GCS4000_Firmware/KDS3_OV2/Generated_Code/SDK/rtos/mqx/config/mcu" -I"C:/Code/GCS4000_Firmware/KDS3_OV2/SDK/platform/osa/inc" -I"C:/Code/GCS4000_Firmware/KDS3_OV2/SDK/platform/utilities/inc" -I"C:/Code/GCS4000_Firmware/KDS3_OV2/SDK/platform/CMSIS/Include" -I"C:/Code/GCS4000_Firmware/KDS3_OV2/SDK/platform/devices" -I"C:/Code/GCS4000_Firmware/KDS3_OV2/SDK/platform/devices/MK64F12/include" -I"C:/Code/GCS4000_Firmware/KDS3_OV2/SDK/platform/devices/MK64F12/startup" -I"C:/Code/GCS4000_Firmware/KDS3_OV2/Generated_Code/SDK/platform/devices/MK64F12/startup" -I"C:/Code/GCS4000_Firmware/KDS3_OV2/Sources" -I"C:/Code/GCS4000_Firmware/KDS3_OV2/Generated_Code" -I"C:/Code/GCS4000_Firmware/KDS3_OV2/SDK/rtos/mqx/mqx/source/nio" -I"C:/Code/GCS4000_Firmware/KDS3_OV2/SDK/rtos/mqx/mqx/source/nio/src" -I"C:/Code/GCS4000_Firmware/KDS3_OV2/SDK/rtos/mqx/mqx/source/nio/fs" -I"C:/Code/GCS4000_Firmware/KDS3_OV2/SDK/rtos/mqx/mqx/source/nio/drivers/nio_dummy" -I"C:/Code/GCS4000_Firmware/KDS3_OV2/SDK/rtos/mqx/mqx/source/nio/drivers/nio_serial" -I"C:/Code/GCS4000_Firmware/KDS3_OV2/SDK/rtos/mqx/mqx/source/nio/drivers/nio_tty" -I"C:/Code/GCS4000_Firmware/KDS3_OV2/SDK/rtos/mqx/mqx_stdlib/source/include" -I"C:/Code/GCS4000_Firmware/KDS3_OV2/SDK/rtos/mqx/mqx_stdlib/source/stdio" -I"C:/Code/GCS4000_Firmware/KDS3_OV2/SDK/platform/hal/src/uart" -I"C:/Code/GCS4000_Firmware/KDS3_OV2/SDK/platform/drivers/src/uart" -std=gnu99 -MMD -MP -MF"Sources/main.d" -MT"Sources/main.o" -c -o "Sources/main.o" "../Sources/main.c"

Building file: ../Sources/os_tasks.c

But as you can see from my .cproject file, I have those files excluded:

   <sourceEntries>
   <entry excluding="Shared/I2C|Sources/os_tasks.c|Sources/main.c|lwip/src/include/ipv6|lwip/src/core/ipv6|.settings/com.freescale.processorexpert.core.prefs" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
   </sourceEntries>

I'm not sure what's going on here.  Perhaps if KDS has a "pre-build event" like Visual Studio, I can have it delete the main.c and os_tasks.c files...

0 Kudos

595 Views
dave408
Senior Contributor II

Thanks, Erich, that is helpful info.  I'm definitely checking in my .project and .cproject files.  In fact, the only ones that aren't checked in are those in the debug folder, and the language XML file.  When I update at home tonight, I'll take a look at what the .cproject looks like.  Thanks again.

0 Kudos