CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

using/compiling multiple files
Goto page 1, 2  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
cerr



Joined: 10 Feb 2011
Posts: 241
Location: Vancouver, BC

View user's profile Send private message

using/compiling multiple files
PostPosted: Mon Mar 28, 2011 11:57 am     Reply with quote

Hi There,

I would like to break up my huge source file into multiple files. I cut all the ISRs out of my main file (MCU2.c) and pasted them into a new file (interrupts.c). I added that to my MPLAB project as a source file. However, can't compile the project, am getting following errors:
Executing: "C:\Program files\Picc\CCSC.exe" +FH LINK="MCU2.hex=MCU2.o,interrupts.o" +DF +LN +T +A +M +Z +Y=9 +EA #__18F87K22=TRUE
*** Error 146 "MCU2.c" Line 1(0,1): Import error dyn mem mis-match true!=false
*** Error 146 "MCU2.c" Line 1(0,1): Import error
2 Errors, 0 Warnings.
Skipping link step. Not all sources built successfully.
BUILD FAILED: Mon Mar 28 10:52:24 2011

The first line in MCU2.c looks like this:
Code:
#include "MCU2.h"
i don't understand what dyn mem mis-match true!=false means. Can someone help me?

Thank you!
cerr



Joined: 10 Feb 2011
Posts: 241
Location: Vancouver, BC

View user's profile Send private message

PostPosted: Wed Mar 30, 2011 12:19 pm     Reply with quote

I thought I got it resolved with this http://www.ccsinfo.com/forum/viewtopic.php?t=34046 but it apparently still isn't working.
If I add another source file under Other files it's all good and it compiles until I declare the function(s) in it in my main header.
Imagine I created a file test.c:
Code:
#include "MCU2.h"
void test (void){
   fprintf(PC,"TEST\r\n");
   }

MCU2.h is my "main-header" - now I can't compile it when I add
Code:
void test(void);
into my MCU2.h - i get all kinds of errors (looks like it doesn't parse mcu2.h at all).... someone able to help?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Mar 30, 2011 2:23 pm     Reply with quote

Here are some more threads on using multiple files in MPLAB:
http://www.ccsinfo.com/forum/viewtopic.php?t=18649&start=1
http://www.ccsinfo.com/forum/viewtopic.php?t=27115
cerr



Joined: 10 Feb 2011
Posts: 241
Location: Vancouver, BC

View user's profile Send private message

PostPosted: Wed Mar 30, 2011 2:27 pm     Reply with quote

PCM programmer wrote:
Here are some more threads on using multiple files in MPLAB:
http://www.ccsinfo.com/forum/viewtopic.php?t=18649&start=1
http://www.ccsinfo.com/forum/viewtopic.php?t=27115


Really, there is no linker.... uh,.... okay :( using #include for the additional c files is the "correct" way to go then I guess... :(

Thanks
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Mar 30, 2011 2:50 pm     Reply with quote

CCS does have something called "multiple compilation units".
See this FAQ:
http://www.ccsinfo.com/faq.php?page=multi_comp_units

But that feature only comes with the "full IDE" version of CCS.
I only buy the individual "command line" versions of the compiler.
So I can't help with multiple compilation units. I only know how to
do the "everything is an #include file" method.
cerr



Joined: 10 Feb 2011
Posts: 241
Location: Vancouver, BC

View user's profile Send private message

PostPosted: Wed Mar 30, 2011 4:07 pm     Reply with quote

PCM programmer wrote:
CCS does have something called "multiple compilation units".
See this FAQ:
http://www.ccsinfo.com/faq.php?page=multi_comp_units

But that feature only comes with the "full IDE" version of CCS.
I only buy the individual "command line" versions of the compiler.
So I can't help with multiple compilation units. I only know how to
do the "everything is an #include file" method.

Uhm okay, my company bought the "full IDE" so that should be possible i see that there's also a tutorial on how to use it with MPLAB, that's good. I'll look at that as well then, thanks a lot for pointing me there!
calvin



Joined: 18 Aug 2010
Posts: 10

View user's profile Send private message MSN Messenger

PostPosted: Tue May 03, 2011 7:07 pm     Reply with quote

In my case, the "Import error dyn mem mis-match true!=false" is when I use "malloc" in my code. if I comment the line with malloc instruction and comment #include <stdlibm.h> works fine.
On the other hand I get few errors when use Multiple complilation units as:
-.CCS shows "File can not be opened for write" with any reason. I have to close CCS, start CCS again and works.
-. The progress bars of RAM and ROM are crazy. shows 100% in ROM (sure, my memory really is not full)
-. Fews errors when I toogle a BookMark and edit the code. May be when a BookMark is located after may code when I delete some files.

Well, I try to help to improve the compiler.

On the other hand, My idea when I try the "Multiple compilation units",was try to locate a code allways in the same directions but Multiple compilation units no works, how can I do to do that? thanks a lot.

I have CCS 4.114
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue May 03, 2011 7:31 pm     Reply with quote

Code:
was try to locate a code allways in the same directions

What is the "same direction" ? Do you mean the same address ?
If so, see the #org statement in this thread:
http://www.ccsinfo.com/forum/viewtopic.php?t=45063&highlight=org
calvin



Joined: 18 Aug 2010
Posts: 10

View user's profile Send private message MSN Messenger

PostPosted: Tue May 03, 2011 9:09 pm     Reply with quote

Thanks for your answer.

Yes, the same address.

I'm trying to do the following:
-. My full code is divided in two parts. One part change frequently. The other part never changes. Like a BootLoader.
-. I locate the second part at bottom of program memory.
-. I use the second part in few microcontrollers
-. When I change the first part, the compilation of the second part is affected and the generated ASM code is no the same between compilations. Remember the second part of my code never changes.

I use the following code to trying to locate my second part of my code and his variables allways in the same address between compilations:
----
addressmod (loader_ram_block,,,START_RAM_ADDR,END_RAM);
#TYPE default=loader_ram_block
#ORG START_ADDR+3, END_ADDR auto=0 default
.
.
.
---

I think the solution of my problem may be possible if:
-. I will able to compile the second part of my code in an separate ".o" file
-. Import the ".o" file of my second part of code to the first part.
-. Compile the first and ".o" and generate the HEX file.
(but I have problems with "multiple units")

I think that in this way I allways have the same ASM of my second part.

An other alternative may be add some directive that allways compile the second part in the same way without changes.

but... I don't know how do that.

Thanks a lot for your advice.

Regards,

Carlos
calvin



Joined: 18 Aug 2010
Posts: 10

View user's profile Send private message MSN Messenger

PostPosted: Tue May 03, 2011 9:28 pm     Reply with quote

And... how can I do to locate all the SCRATCH variables generated by the compiler in an specific location?

I can locate the variables declarated in my functions like: int XX; char FF[20], etc. using:

addressmod(ram_block,,,START_RAM_ADDR,END_RAM);
#TYPE default=ram_block

But how can I do the same thing with the SCRATCH variables?

Thanks again for your help.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue May 03, 2011 9:57 pm     Reply with quote

This thread talks about the issue:
http://www.ccsinfo.com/forum/viewtopic.php?t=27996
calvin



Joined: 18 Aug 2010
Posts: 10

View user's profile Send private message MSN Messenger

PostPosted: Tue May 03, 2011 11:01 pm     Reply with quote

Thanks PCM, do you have some advice about my others situations? and some for "Import error dyn mem mis-match true!=false"?

Thanks
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue May 03, 2011 11:27 pm     Reply with quote

I don't have the full IDE version of the CCS compiler, so I can't test
problems with Multiple Compilation Units. I have the command line
compilers that integrate with MPLAB. They don't support "MCUs".
calvin



Joined: 18 Aug 2010
Posts: 10

View user's profile Send private message MSN Messenger

PostPosted: Wed May 04, 2011 12:34 am     Reply with quote

Thanks a lot PCM!
arnadan



Joined: 11 Nov 2013
Posts: 13

View user's profile Send private message

error dyn mem mis-match true!=false
PostPosted: Fri Dec 13, 2013 10:00 am     Reply with quote

Very old post but still no solution! So I had to find a solution by myself and want to share it here:

Include the following line in all of your *.C files (respectively in the common project.h file that I include in every *.C file):

#USE DYNAMIC_MEMORY

After that you will get some "Variable never used: __DYNAMIC_HEAD" warnings but the code compiles, links and executes.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group