[Gcc-coco-os-9] Compiler options - GNU .v.s. ANSI
Status: Beta
Brought to you by:
skwirl42
From: John E. M. <wb...@qs...> - 2003-11-05 04:54:56
|
First, Hello to who ever is also on this mailing list. Next, I looked up to see if GCC supports the GCC the #pragma directive. What I found is that they do not like it, and have implemented a __attribute__(x) feature. They are providing limited #pragma for compatability with source code meant for other platforms. It seems to me the best way to implement this for code that you would want to be able to build on both the COCO and other plaforms would be to use a macro structure like: #ifdef __6809 #define direct __attribute__(direct) #else #define direct #endif direct int foo; Normally on an ANSI compliant compiler, such an attribute would be defined with a similar sequence: #ifdef __COMPILER_NAME #ifdef __6809 #pragma section_name save #pragma section_name ".direct." #endif #endif int foo; #ifdef __COMPILER_NAME #ifdef __6809 #pragma section_name restore #endif #endif So as you can see, the GNU way is much clearer to read than the ANSI method. Because #pragma directives are compiler specific, they need to be conditionally compiled around the #pragma directives. Theoretically a compiler should ignore #pragma directives that it does not understand, but there is no coordination of the namespace so it is possible that a compiler could misunderstand a #pragma that is not meant for it. -John wb...@qs... Persoanl Opinion Only |