|
|
View previous topic :: View next topic |
Author |
Message |
Gabriel
Joined: 03 Aug 2009 Posts: 1067 Location: Panama
|
Function declaration order |
Posted: Sun Aug 23, 2020 10:08 am |
|
|
Hi All,
When declaring structs the variables inside are ordered by their size: floats first, then int16s, then int8s and ints1, as needed... right.
So my question is if this also applies to function declarations?
voids first, int16 types, etc...
I've always organized them by functionality/or resource without any issues... but lately I've been using a ton of structs and it got me thinking it might matter here too... and with variable declarations too by extension.
I'd appreciate any "good practices" recommendation here... i have a massive code cleanup going on.
G. _________________ CCS PCM 5.078 & CCS PCH 5.093 |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19496
|
|
Posted: Sun Aug 23, 2020 10:22 am |
|
|
The compiler re-orders the functions to make them fit in the available
memory pages.
The algorithm is 'reasonable', but not 'brilliant'. So (for instance), if you
have a chip that has a particular page size, and allows four pages, then
declare five large functions, though it is actually possible to fit them
(perhaps fitting the two smallest functions into one page), the compiler
may fail to spot this. It gets it to work 99% of the time where it is
possible. |
|
|
avatarengineer
Joined: 13 May 2013 Posts: 51 Location: Arizona
|
int1 in structs |
Posted: Mon Aug 31, 2020 2:33 pm |
|
|
int1 are created from a byte,
therefore whether you have 1 int1 or 8, both conditions use a byte.
Code: |
struct {
int1 F4Khz,F2KHz,F1KHz,Blink;
int1 FastBlink,SlowBlink,StnbyBlink,TickSec;
int1 Ops1mS,Ops5mS,Ops10mS,Ops50ms;
int1 Ops250ms,a,b,c;
} Timerbits;
I add dummies in the struct to remind me of unused
int1 bits in the byte.
|
Also, I asked the question before about order of PICC declarations
and I recall a reverse order, int1 bytes, bytes, words, longs,floats.
Can this be verified? |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9221 Location: Greensville,Ontario
|
|
Posted: Mon Aug 31, 2020 6:21 pm |
|
|
Hmm. perhaps the 'program_name.sym' file has what you need to know ?? Pretty sure it's the one with the RAM and ROM allocations in it ?
Jay |
|
|
|
|
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
|