This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Question about #pragma removal


I noticed your removal of the #pragma pack mechanism in favor of the
__attribute__ mechanism.  The documentation indcates:
Some people object to the __attribute__ feature, suggesting that ANSI C's
#pragma should be used instead. There are two reasons for not doing this. 
	It is impossible to generate #pragma commands from a macro. 
	There is no telling what the same #pragma might mean in another
compiler. 
These two reasons apply to almost any application that might be proposed for
#pragma. It is basically a mistake to use #pragma for anything. 

What I don't understand is how __attribute__ eliminates this problem.  I
cite the following examples:

1)  There is no telling what the same __attribute__ might mean to another
compiler
2)  For compiler specific features, such as the #pragma, or the
__attribute__ feature, it is a mistake to not surround these lines with
preprocessor statements such as '#ifdef GNU_C' or '#ifdef MSC'.

Basically, all this does is create further extensions to the C language that
are non-ansi.  Seems like Microsoft does the same sort of thing all the time
(take JAVA for example).

Anyway, I'd be interested in hearing an explanation (other than the two
lines in the documentation) as to why #pragma is unacceptable.
By the way, I completely understand the second argument regarding generating
#pragma commands from a macro.  I'd even go further to say a weakness of C
is that there is no way to generate pre-processor statements from other
pre-processor statements.  For instance, you can't generate a #define from a
macro either.

Thanks,
-Brett


-----------------------------
Brett A. Cook
Senior Software Engineer
Intel Corp.
2569 Park Lane, Suite 202
Lafayette, CO  80026
303-665-2286  x139
-----------------------------


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]