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

Data Definitions

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



Joined: 14 May 2023
Posts: 30

View user's profile Send private message

Data Definitions
PostPosted: Thu Aug 03, 2023 1:56 pm     Reply with quote

Hello,

Is there a limit on how many variables can be used in a data definition?


example:
void writeRegisterI2C(int8 deviceAddress, int8 address, int8 val);
temtronic



Joined: 01 Jul 2010
Posts: 9118
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Thu Aug 03, 2023 7:34 pm     Reply with quote

Probably more than you can keep track of...(my gut says 255 )
Really, passing a lot of variables in a single function will be a nightmare. I suspect once you get to 10 or 12 it get 'challenging' to remember what they're supposed to do.I can say I've ever seen any code use more than 8 or 9.
I'd like to know how many you need to pass.
Ttelmah



Joined: 11 Mar 2010
Posts: 19233

View user's profile Send private message

PostPosted: Fri Aug 04, 2023 3:28 am     Reply with quote

C historically had a limit of 127.
ANSI C90 only requires 31 is the minimum supported. So code that
is intended to be portable should not use more than this.
Generically though a function that has a huge number of variables, should
probably be split into a number of smaller functions, just on efficiency
grounds.
There is also a line length limit in the compiler, and unless the variables
use very small names, this will probably be hit first.
Remember also, a structure is a single variable, and could contain hundreds
of sub components. Much easier to pass a singe entity like this than
have loads of separate items.
temtronic



Joined: 01 Jul 2010
Posts: 9118
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Fri Aug 04, 2023 7:48 am     Reply with quote

hmm... magical 'binary' numbers...!!!!
255..127, 31
Blackjackmaster



Joined: 14 May 2023
Posts: 30

View user's profile Send private message

Data Definitions
PostPosted: Fri Aug 04, 2023 9:03 am     Reply with quote

Thanks for the information.

I was looking in the manual for what the line length is and was unable to find this number. I will be passing 6 variables with one function. I will keep the name as short as possible.
Ttelmah



Joined: 11 Mar 2010
Posts: 19233

View user's profile Send private message

PostPosted: Fri Aug 04, 2023 11:43 am     Reply with quote

6 wouldn't be a problem even with long names.
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