This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Hey All,
I'm having a very strange issue I'm hoping you can help with. I am using C++ on a custom board using an RM42 to process data from my design teams project (I am a student so feel free to correct any errors you find here). I have zipped our entire project up and attached it so you guys can view everything (there is a lot of custom code).
My program initializes a class object as a global variable on start up named 'ccbus' which is of type 'CCBus' (source/sys_main.cpp @ 182). My CCBus object has a member variable (modules/CCBUS/ccbus.h @ 39) which is an array of pointers to a base class. Inside my main function (source/sysmain.cpp @ 261) I call an init function to allocate the child class objects into the array (modules/CCBUS/ccbus.cpp @ 450).
void CCBUS::CCBus::initCardList() { /* ID = # ID CCBUS::Cards::BaseCard * CCBUS::Cards::CARD_ID */ /* ID = 0 (NULL) */ cardList[ 0 ] = NULL; /* ID = 1 (ALL) */ cardList[ 1 ] = NULL; /* ID = 2 (MIN) */ cardList[ 2 ] = new CCBUS::Cards::PowerCard( 2 ); // CARD_TYPE_POWER /* ID = 3 */ cardList[ 3 ] = NULL; // CARD_TYPE_DRIVER_ASSISTANCE /* ID = 4 */ cardList[ 4 ] = NULL; // CARD_TYPE_PC /* ID = 5 */ cardList[ 5 ] = new CCBUS::Cards::SafetyCard( 5 ); // CARD_TYPE_SAFETY /* ID = 6 */ cardList[ 6 ] = NULL; // CARD_TYPE_DUCHESS_CAR /* ID = 7 */ cardList[ 7 ] = NULL; // CARD_TYPE_ARTEMIS_CAR /* ID = 8 (MAX) */ cardList[ 8 ] = new CCBUS::Cards::RinehartCard( 8 ); // CARD_TYPE_RINEHART_MOTOR_CONTROLLER /* ID = CARD_ID_COUNT */ return; }
My issue is that when compiled the memory allocation for ID = 8 is skipped entirely, it is not visible in the disassembly.
However, when I call
ccbus.cardList[8] = new CCBUS::Cards::RinehartCard( 8 );
in my main function everything is fine. I have similar code (modules/ is identical and main is the same) running in a different project for a RM46 board and the same thing happens.
Any ideas as to why this line will not compile and execute? @mods: If this is better suited to the Compiler section of the forum please move it!
Thanks,
Nathan
There is a control-M (carriage return, CR) in the code instead of a control-J (new line, LF). This is fairly common when accessing a unix-format file on Windows. Windows files use both characters at once (CR+LF), unix uses just LF.