|
|
View previous topic :: View next topic |
Author |
Message |
mgillespie
Joined: 19 Feb 2009 Posts: 7
|
#MODULE not working? |
Posted: Tue Apr 14, 2009 10:42 am |
|
|
Hi, I have been given some PIC code written by a non-software engineer to tidy up and make conform to our coding standards, the problem is, the coding is horrendous in places, with some abysmal coding practices (not surprised, as the CCS help file examples are not that much better with code and prototypes in the same file for example).
Trying to factor some code out to modules, and separate stuff into private data and public access methods, something it seems many PIC C "hackers" don't do, leaving everything global.
Anyway, my reading of the #MODULE command, is that anything after the #MODULE until the end of the file will be private data, so I can put my public functions above and then have some kind of code scope.
However it does not seem to work (CCS V4.090). I hide away some enums that are needed by other modules, and everything compiles just fine still.
Confused.. Is my understanding of #MODULE wrong?
Thanks,
PS. I'm not totally surprised that PIC C programmers don't use modules, as the IDE is very difficult to use with multiple compilation units (actually the IDE is pretty bad full stop, I can't even use Ctrl+F on a highlighted file to find the next occurrence without having to copy and paste the word into the find field...). |
|
|
Guest
|
|
Posted: Tue Apr 14, 2009 11:58 am |
|
|
Hmmm, did you come here for help, or to editorialize? If we "hackers" are so bad, why ask for our help? If the compiler/IDE is so bad, why use it?
Tom |
|
|
bsturm
Joined: 23 Feb 2009 Posts: 29
|
|
Posted: Tue Apr 14, 2009 12:10 pm |
|
|
Have you programmed a PIC before? They don't have much in the way of stack or ram, therefore it is common to have more global vars than a larger chip or a PC would. You cannot fit too many pages of code into the smaller PIC's. For the 18F and higher the situation is better, but many people started on the older smaller chips. |
|
|
asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
|
|
Posted: Tue Apr 14, 2009 12:49 pm |
|
|
the DOC for #module does seem to work for me as the compiler manual states, tho i have used it VERY rearely.
But why you think you need to use it in your case is unclear.
i do understand a bit of your frustration.
However -
Not knowing WHICH PIC you are programming - i can only offer a few basic suggestions:
1- accept the global scope of the program and declare your global VARs
at or near the head of your source listings
2- declare all other vars as local vars inside your functions, as needed.
3- organize functions in order of hierarchy
ie: MAIN() LAST and all subsidiary functions in the order of minimum dependency so that a function used extensively by many other functions would perhaps be the FIRST one in the source file
4- TEST compile chunks of code you are uncertain of and read the .LST file to SEE what you got for your trouble
5- - avoid floating point vars for ANYTHING / everything if U can - unless you need it. and there is no other way.
6- be patient and don't always assume YOUR problem is a faulty compiler or bad doc. I've found that sometimes i was just in too big a hurry to stop and read enuf of the doc to get my ashes hauled right.
6B- Patience II The SEARCH function on this BBS has saved me many ( tho not all ;-)) ) the embarrassing post(s) here .
The more patient I've been - the more success I've had with CCS. |
|
|
Franck26
Joined: 29 Dec 2007 Posts: 122 Location: Ireland
|
|
Posted: Tue Apr 14, 2009 3:51 pm |
|
|
Hi mgillespie,
I cannot help you, but just confirm that it's very difficult to do a clean code since the multi compilation units is still not working, and #module do not replace it properly...
To answer the post number 2 ("If the compiler/IDE is so bad, why use it? ") I suppose that you did like me: I read all the promises from CCS, I believed it and now I've a buggy IDE and no support from CCS.
It looks like they have enough work on the compiler itself...
Good luck,
Franck. |
|
|
|
|
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
|