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

how to pass 2 dimentional CONST array to a function?

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Coder
Guest







how to pass 2 dimentional CONST array to a function?
PostPosted: Tue Apr 13, 2004 5:18 pm     Reply with quote

Hi..

im trying to pass a 2 dimentional CONST array to a function. i know i cant use a pointer to a CONST. what other way is there?

the array is one comprised of char . for eg.

char CONST menu_items[8][16]={"1.TX Frequency","2.Audio Subcar","3.Test Signal","4.TX on/off","5.Standby","6.Audio Meter","7.Battery Meter","8.Exit"};

im in a fix . any help would be greatly appriciated

coder
Steve H
Guest







PostPosted: Tue Apr 13, 2004 7:50 pm     Reply with quote

As I understand it a CONST was added to the C language so that a compiler would know to use a fast RAM IO location to store the value instead of inline with the code or some slow memory spot. That makes sense on BIG computers and BIG programs.

I wonder if you just make them variables with an appropriate comment that they should not change, etc, etc - what the difference would be?

The CCS compiler won't do anything differently with the values, right?

The simplest, fastest and probably safest thing to do is to make them globals and not pass them to functions - especially with small programs like would typically be found in a PIC.

I always try to think "Small C" when programming and I try to limit passing variables, etc. Let's face it the goal is to have code efficiency with a PIC. I find that most programs are well under 25 to 50 pages of source and involve only one programmer - so the simpler the better.

My thoughts on the matter - everyone elses milage may vary... ;-)

Steve H.
Haplo



Joined: 06 Sep 2003
Posts: 659
Location: Sydney, Australia

View user's profile Send private message

PostPosted: Wed Apr 14, 2004 7:10 am     Reply with quote

Well said. Making them global is the best choice in my opinion too.

When I code for PICs, I also tend to use global variables a lot, and I usually avoid passing variables to functions if I can. This may not be a good programming practice on MSVC and all that, but my experience shows it generates the smallest and most efficient code for the PIC. Embedded coding is an art in its own way.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
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