DSPRelated.com
Forums

Including an .ldr file in a c file...

Started by Kannan Subranian August 23, 2000
Hello,
I am working on Sharc Vdsp(4.1) toolset with the patches.
I wish to include a .ldr file in a C file.
I followed the guide lines in theVDSP users guide and reference manual.(page A-9 of File formats) if i include the .ldr in that way iam getting a compilation error indicating '# not expected at this place'
can i get more info on the "loader include file formats (.ldr) "
and how to include them on C/asm files
thanks and regards,
kannan
Systems Engineer.
 



On Wed, 23 Aug 2000 17:17:12 +0100, Kannan Subranian wrote:

> I am working on Sharc Vdsp(4.1) toolset with the patches. I wish to
> include a .ldr file in a C file. I followed the guide lines in
> theVDSP users guide and reference manual.(page A-9 of File formats)
> if i include the .ldr in that way iam getting a compilation error
> indicating '# not expected at this place' can i get more info on the
> "loader include file formats (.ldr) " and how to include them on
> C/asm files

Found what you're referring to, in the linker manual, under "Loader
Include Format Files (.LDR)", page A-9. An example is provided on
page A-10. I think the example is wrong, as its shows the type of the
array to be float[] instead of unsigned[]. It should also be
unnecessary to pre-specify the array size. Instead, use something
like this:

const unsigned loader_file[] = {
#include "foo.ldr"
};
const unsigned loader_file_count
= sizeof loader_file / sizeof loader_file[0];

I also note that in the example ADI gives, the loader file lacks a
comma at the end of each line of data. Is this true with an actual
.LDR file? If so, then the loader program is broken. Only the last
line should lack a trailing comma. You could probably use sed or awk
from Cygwin to fix the file. (Cygwin is at
http://sourceware.cygnus.com.)

You may want to try running the preprocessor by itself to see what
the compiler is complaining about:

cc21k -E [other options] -o foo.i foo.c

Then compile the result:

cc21k -c [other options] -o foo.doj foo.i

This should clarify where the real problem is.

Kenneth Porter
Kensington Laboratories, Inc.
mailto:
http://www.kensingtonlabs.com



Yes, the example in the manual does indeed contain errors. The data type for
the array should be unsigned, not float. The include format loader file is
comma delimited except for the last word. Also, it is required that any #
directives be placed as the first characters on a given line, since the
preprocessor will recognize them only if they are in that first position.

Thank you Ken for pointing out the errors. They will be fixed in the next
edition. > DSP Support
>
> Analog Devices, CPD
> 3 Technology Way
> Norwood, MA 02062-9106
>
> Email:
> Phone: 1-800-ANALOGD
> Fax: 781.461.3010
> FTP: ftp.analog.com
> WEB: www.analog.com
> DSP EZ-Answers: http://www.analog.com/dsp/EZ/index.html > ----------
> From: Kenneth Porter[SMTP:]
> Reply To: Kenneth Porter
> Sent: Wednesday, August 23, 2000 4:04 PM
> To: Support, DSP
> Subject: Re: [adsp] Including an .ldr file in a c file...
>
> On Wed, 23 Aug 2000 17:17:12 +0100, Kannan Subranian wrote:
>
> > I am working on Sharc Vdsp(4.1) toolset with the patches. I wish to
> > include a .ldr file in a C file. I followed the guide lines in
> > theVDSP users guide and reference manual.(page A-9 of File formats)
> > if i include the .ldr in that way iam getting a compilation error
> > indicating '# not expected at this place' can i get more info on the
> > "loader include file formats (.ldr) " and how to include them on
> > C/asm files
>
> Found what you're referring to, in the linker manual, under "Loader
> Include Format Files (.LDR)", page A-9. An example is provided on
> page A-10. I think the example is wrong, as its shows the type of the
> array to be float[] instead of unsigned[]. It should also be
> unnecessary to pre-specify the array size. Instead, use something
> like this:
>
> const unsigned loader_file[] = {
> #include "foo.ldr"
> };
> const unsigned loader_file_count
> = sizeof loader_file / sizeof loader_file[0];
>
> I also note that in the example ADI gives, the loader file lacks a
> comma at the end of each line of data. Is this true with an actual
> ..LDR file? If so, then the loader program is broken. Only the last
> line should lack a trailing comma. You could probably use sed or awk
> from Cygwin to fix the file. (Cygwin is at
> http://sourceware.cygnus.com.)
>
> You may want to try running the preprocessor by itself to see what
> the compiler is complaining about:
>
> cc21k -E [other options] -o foo.i foo.c
>
> Then compile the result:
>
> cc21k -c [other options] -o foo.doj foo.i
>
> This should clarify where the real problem is.
>
> Kenneth Porter
> Kensington Laboratories, Inc.
> mailto:
> http://www.kensingtonlabs.com >