smpoojary
asked on
#pragma section
What is the purpose of "#pragma section". In two different header files if same '#pragma section' is defined, then what will happen? If we defined in two different header files of same pragma, how to remove it as preprocessor #undef xyz. I am getting following error
typedef char system_name_def[10];
^
"D:\Clearcase\for_os upgrade\mr\smsc\lib/./../e xports/inc lude/smpdl .h", line 173: warning(382):
typedef name has already been declared (with same type)
In file smpdl.h
===========
#pragma section system_name
typedef char system_name_def[10];
I need full description about the "#pragma section". Tried in google, difficult to digest.
typedef char system_name_def[10];
^
"D:\Clearcase\for_os upgrade\mr\smsc\lib/./../e
typedef name has already been declared (with same type)
In file smpdl.h
===========
#pragma section system_name
typedef char system_name_def[10];
I need full description about the "#pragma section". Tried in google, difficult to digest.
>> I need full description about the "#pragma section". Tried in google, difficult to digest.
Did you read this ?
http://msdn2.microsoft.com/en-us/library/50bewfwa(VS.80).aspx
Did you read this ?
http://msdn2.microsoft.com/en-us/library/50bewfwa(VS.80).aspx
What compiler are you using?
ASKER
Answer is depending on the compiler
1)One says: "Writing Interrupt Handlers"
we can create a new named section using the "#pragma section" compiler extension. In order to store something in ROM/FLASH, it must be either code or a const variable otherwise it is stored in RAM. for example
#pragma section CODE=prog2, locate=0xFF0000.
Finally if we want to locate variable out of 64kb memory, this is useful.
2)Another one says:
When variables are defined by using the #pragma section, they are located in the order in which they have been defined.
Example:
#pragma section sdata begin
unsigned short a;
unsigned short b;
unsigned short c;
#pragma section sdata end
Actually I was looking for (2) option.
Thanks for help.
1)One says: "Writing Interrupt Handlers"
we can create a new named section using the "#pragma section" compiler extension. In order to store something in ROM/FLASH, it must be either code or a const variable otherwise it is stored in RAM. for example
#pragma section CODE=prog2, locate=0xFF0000.
Finally if we want to locate variable out of 64kb memory, this is useful.
2)Another one says:
When variables are defined by using the #pragma section, they are located in the order in which they have been defined.
Example:
#pragma section sdata begin
unsigned short a;
unsigned short b;
unsigned short c;
#pragma section sdata end
Actually I was looking for (2) option.
Thanks for help.
ASKER
Hi Moderator,
Could you please close this question if there is no objections. Solution is pasted in my above comments.
Regards
-Mahesh
Could you please close this question if there is no objections. Solution is pasted in my above comments.
Regards
-Mahesh
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
will include file only once.
(2)
#ifndef __YOURFILE_H
#define __YOURFILE_H
.......all header file codes......
#endif
this avoids 2nd time inclusion of same file.
syntax is :
#pragma pragma-name pragma-arguments
(there are few names for pragma-name, i am not aware of all.)