Hi all, I would like to investigate the use of pragmas in GCC. What are pragmas, how are they used, what are their limitations, and how can they be used to carry information from the source code to various optimizing passes. Specifically, I would like to investigate how pragmas can be used to allocate variables to specific memory banks. Can anybody give me a summary, or a link to a document where I can find such details? Thanks!
Marc Khayat wrote: > Hi all, > I would like to investigate the use of pragmas in GCC. What are > pragmas, how are > they used, what are their limitations, and how can they be used to > carry information from > the source code to various optimizing passes. http://gcc.gnu.org/onlinedocs/gcc-4.1.2/gcc/Pragmas.html#Pragmas > Specifically, I would > like to investigate how pragmas can be used to allocate variables to > specific memory banks. Memory-Addresses get assigned by the linker. A possibility to place variables in a special addresse-range is to add a section attribute with a section name to the variable declaration and modify the linker-script to take this section into account. Make sure the variables get initialised correclty (similar to "copy .data" and "zero init .bss") > Can anybody give me a summary, or a link to a document where I can > find such details? http://gcc.gnu.org/onlinedocs/gcc-4.1.2/gcc/Variable-Attributes.html#Variable-Attributes http://sourceware.org/binutils/docs-2.17/ld/index.html
#pragma directives are merely arbitrary compiler directives. The can be used for anything the author of the compiler wishes. There is no standardisation on what directives a compiler support, and the syntax, semantics and naming of any particular directive are specific to the compiler and should not be expected to be portable. The required ISO behaviour when a compiler encounters a pragma it does not recognise is simply to ignore it - so a pragma in your code may in fact be having no effect whatsoever if it was intended for a different compiler. GCC generally eschews using pragma directives altogether and very few are supported, and then mostly for compatibility with specific compilers to for architecture specific features. Most uses of #pragma are replaced with function, type or variable attributes in GCC. This is a compiler extension, but at least it will fail to compile in another compiler rather than quietly ignoring it as it would a pragma. Now if hopefully that is all clear, the answer to your question is in the GCC manual (supplied with WinARM and also at http://gcc.gnu.org/onlinedocs/), specifically the section titled "Pragmas Accepted by GCC", section numbervaries depending on the version 5.50 in 4.2.0, and 5.49 in 4.1.2. In general I would suggest that in GCC pragmas are not provided for any of the purposes you have suggested in GCC. I am not sure why you are so interested in pragmas, by definition, they are something you only need (or want) to use in vary rare circumstances and should be avoided wherever possible - especially in GCC. Clifford
Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
Log in with Google account
No account? Register here.