Hello Rich,

This is nothing memory space related. If you would change from char to int
or worse float, you would get into the same trouble.

To solve this C invented header files. You learn yourself never to put an
extern declaration or function prototype in a .c file but always in a .h
file which you subsequently #include. And not only in the file that uses
the reference but also in the file that defines the variable or function.
This way the compiler will check the declaration against the definition
and throw an error if they do not match.

Maarten

> Hello SDCC, I've been using SDCC for programming MCS51 micros.  My
> program is split up into multiple files, such as main.c/h, then
> file1.c/h, file2.c/h, etc. Global variables are declared in the beginning
> of each .c file.  Then if the global variable is referenced in another .c
> file, an extern is added in the beginning of the other .c file.  So when
> done properly, it would look like this:file1.c:   __idata char var1
> =1;file2.c:  extern __idata char var1; So far, so good, and everything
> works great. Then later on I'm editing things and change the
> declarations incorrectly, such as this:file1.c:   __xdata char var1
> =1;file2.c:  extern __idata char var1; Notice that file1 says xdata,
> while file2 says idata. This compiles and links fine, but doesn't run
> properly due to mixed up memory accesses.  Then I have to hunt down the
> error, usually among the last changes made of course. My question is, is
> there some tool/flag/setting that will provide a warning about this
> error?  Something in the linker? Thanks,  Rich.   


------------------------------------------------------------------------------
Monitor Your Dynamic Infrastructure at Any Scale With Datadog!
Get real-time metrics from all of your servers, apps and tools
in one place.
SourceForge users - Click here to start your Free Trial of Datadog now!
http://pubads.g.doubleclick.net/gampad/clk?id=241902991&iu=/4140
_______________________________________________
Sdcc-user mailing list
Sdcc-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sdcc-user

Reply via email to