This is the mail archive of the crossgcc@cygnus.com mailing list for the crossgcc project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
> I have a few #define in a .h file that are needed by C, asm > and linker. Is there a way to do this without declaring them in > 3 files. It is definitely possible to share .h files between C and assembler; almost _all_ of the header files in the system I'm now working on are used that way. What I do is to hide the C-specific stuff under an #if defined(_LANGUAGE_C) clause, and make the assembler-specific stuff under the #else, as in the following file: /* * gdb_stub.h - interface to gdb stub (debug agent) * * THIS SOFTWARE IS NOT COPYRIGHTED * * The following software is offered for use in the public domain. * There is no warranty with regard to this software or its performance * and the user must accept the software "AS IS" with all faults. * * THE CONTRIBUTORS DISCLAIM ANY WARRANTIES, EXPRESS OR IMPLIED, WITH * REGARD TO THIS SOFTWARE INCLUDING BUT NOT LIMITED TO THE WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ #ifndef _GDB_STUB_H #define _GDB_STUB_H #if defined(_LANGUAGE_C) void handle_debug_exception (long long *saved_registers); #else /* if !defined(_LANGUAGE_C) */ .globl handle_debug_exception #endif /* defined(_LANGUAGE_C) */ #endif /* _GDB_STUB_H */ In the general case (though not in this example) there would be #defines outside the #if defined(_LANGUAGE_C) clause, and these would be visible to both the C and assembler modules. > I tried to #include the .h file in the assembley file and feed it to > the c preprocessor. The output had the #include file data in it, so 'as' > choked. > > What parameters should I pass to the preprocessor to get it to output > something that can be fed to AS? > or How can I do the above step in 1 shot. gcc recognizes the suffix .S (upper case S) as meaning an assembler file which should go through the preprocessor, and will process that correctly. > I am compiling in a dos box under NT and make (or NT) doesn't see .S and > .s files as different, it treats both as assembler. Is this an issue? YES IT MOST DEFINITELY IS. Although I use x86 Solaris, my partner refuses to use Unix of any flavour, so I set up a compiler for him which runs in a dos box under Windows 3.11. On the latter system we change all of the suffixes from .S (which can't be represented under dos -- go32 lowers the case of all 8+3 filenames) to .asm (which _can_ be represented) and add the switch -x assembler-with-cpp to the gcc invocation line. Not elegant, but it does the trick. > I need to allocate a block of memory in the linker file. > The size of the block is a function of values declared in the .h > file but the location must be specified by the linker > > Can I pass a value from a 'c' style #include file to the linker? If you find out how to do this please tell me how you did it. Mike -- C. M. Heard VVNET, Inc. phone: +1 408 247 9376 4040 Moorpark Ave. Suite 206 fax: +1 408 244 3651 San Jose, CA 95117 USA e-mail: heard@vvnet.com