Hi Rich,

Maarten already said it in some way and I just like to add my thoughts
to this issue:

The linker usually doesn't know anything about data types and memory
modifiers and such. Having said this, it is the object file (*.o or
*.rel) that misses this information. Actually, most linkers and C
systems I know work this way. The only thing that is stored is the
symbol's name with an attribute of being defined or referenced.

The professional (say: correct) way to handle this is to write a header
file for each module like you said in your introduction. This header
file holds declarations of each and every publicly used object (types,
variables, functions, you name it) of its source companion. The file is
included in any source file that makes use of any of these objects. To
make sure you don't screw up your project the header is also included in
the source file it belongs to.

In your example:

file1.h:
extern __idata char var1;

file1.c:
#include "file1.h"
__idata char var1;

file2.c:
#include "file1.h"

If you have any discrepancies between declaration in the header and the
definition in the source, the compiler will remind you with some nice
warning or error.

Additional value: you don't have to remember which other source files
use another source's object if you change its footprint. You will just
edit the header and everything is fine. I hope you know how to use
"make" and actually use it. ;-)

Hope that helps,
Bodo

------------------------------------------------------------------------------
_______________________________________________
Sdcc-user mailing list
Sdcc-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sdcc-user

Reply via email to